mufidu / booku

0 stars 1 forks source link

Sweep: Create unit test for invalid string in books by category endpoint #85

Closed mufidu closed 5 months ago

mufidu commented 5 months ago

Details

File: booksCategorytest.js. Endpoint: /books/category/:authorName. User can sometimes insert invalid characters as string, prepare for that by testing it.

Checklist - [X] Modify `test/bookCategory.test.js` ✓ https://github.com/mufidu/booku/commit/a18d7e99791fbc618cdbb7a15332e96db729aaf4 [Edit](https://github.com/mufidu/booku/edit/sweep/create_unit_test_for_invalid_string_in_b_a5db1/test/bookCategory.test.js) - [X] Running GitHub Actions for `test/bookCategory.test.js` ✓ [Edit](https://github.com/mufidu/booku/edit/sweep/create_unit_test_for_invalid_string_in_b_a5db1/test/bookCategory.test.js)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #86

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 610b73639a)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/mufidu/booku/blob/f73bd76c3414612a302aa964ada0fb14cd0de17c/test/bookCategory.test.js#L19-L65

Step 2: ⌨️ Coding

--- 
+++ 
@@ -30,6 +30,19 @@
                     res.body.forEach(book => {
                         expect(book.category).to.equal('Fantasy');
                     });
+
+    describe('Handling invalid category names', () => {
+        it('should return a 400 status code with an appropriate error message for an invalid category name', done => {
+            chai.request(server)
+                .get('/books/category/!nvalidC@tegoryName')
+                .set('Authorization', `Bearer ${token}`)
+                .end((err, res) => {
+                    expect(res).to.have.status(400);
+                    expect(res.body.error).to.equal('Invalid category name.');
+                    done();
+                });
+        });
+    });
                     done();
                 });
         });

Ran GitHub Actions for a18d7e99791fbc618cdbb7a15332e96db729aaf4:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/create_unit_test_for_invalid_string_in_b_a5db1.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.