Conversation
Contributor
|
Generated by GitHub Advanced Security tool as code quality fixes. |
…mver comparison, and d1-mock correctness Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix risky non-null assertion in version middleware tests
Fix test quality issues: null assertion, misleading test name, arrow-function Mar 17, 2026
this, semver comparison, and changed_db flag
admdly
approved these changes
Mar 17, 2026
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
api-worker | d5bf11c | Commit Preview URL Branch Preview URL |
Mar 17 2026, 12:41 PM |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves correctness and clarity in the test suite by removing risky assertions, aligning test names with actual behavior, and fixing logic errors in the D1 mock used by tests.
Changes:
- Harden ETag-related middleware test by asserting ETag presence before use (removing the non-null assertion).
- Rename a misleading middleware test to match the exercised 503/GitHub-failure code path.
- Fix D1 mock behavior by using numeric semantic version comparison, removing
thisaliasing via arrow functions, and makingchanged_dbreflect whether a DELETE actually removed a row.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/utils/d1-mock.ts | Fixes semver range filtering, this handling in prepared statements, and DELETE metadata accuracy in the mock D1 implementation. |
| test/services/versions/v1/middleware.test.ts | Makes ETag usage safer and renames a test to accurately describe the GitHub API failure behavior being asserted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several correctness and clarity issues in test utilities and middleware tests, ranging from a risky non-null assertion to a semantically wrong version-range comparison in the D1 mock.
middleware.test.tsetag!with a precedingexpect(etag).toBeTruthy()assertion andetag as stringcast, making the failure explicit rather than a silent runtime error."should set Vary header when returning empty results"→"should not set Vary header when GitHub API fails"— the test hits the 503 code path where the app never setsVary, so the name andtoBeNull()assertion now match both each other and the actual application behaviour.test/utils/d1-mock.tsRemove
thisalias: dropconst mockDb = this+ its eslint-disable comment; convertbindand allD1PreparedStatementmethods to arrow functions sothisis theMockD1Databaseinstance throughout via lexical closure.Semver comparison: replace string
>=/<=version comparison (wrong for e.g."0.10.0" <= "0.2.0") with proper numeric component comparison:changed_dbflag in DELETE: was unconditionallytrue; changed towasDeletedto accurately reflect whether a row was actually removed.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.