test: write unit tests for lib/github.cjs (#134)#147
Merged
snipcodeit merged 1 commit intomainfrom Mar 2, 2026
Merged
Conversation
Add comprehensive unit tests for all 10 exported functions in lib/github.cjs using node:test built-in runner with execSync mocked via module cache invalidation — no real gh CLI calls made. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This was referenced Mar 2, 2026
Owner
Author
|
We need to add a deployment ci cd run this to ensure nothing breaks. |
This was referenced Mar 2, 2026
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.
Summary
test/github.test.cjswith 46 test cases covering all 10 exported functions inlib/github.cjsdelete require.cache+mock.method(childProcess, 'execSync', ...)) so no realghCLI calls are made during test runsexecSyncthrows propagate correctlyCloses #134
Milestone Context
Changes
test/github.test.cjs(new, 684 lines) — full unit test suite forlib/github.cjsgetRepo— 2 tests: correct command construction, error propagationgetIssue— 4 tests: parsed return value, command shape (number + fields), string arg, error pathlistIssues— 8 tests: no-filter base case, each filter flag (--label,--milestone,--assignee,--state),assignee: "all"exclusion, error pathgetMilestone— 3 tests: parsed return value, two-call sequence (getRepo then gh api), error pathgetRateLimit— 4 tests: field values, command, no extra keys, error pathcloseMilestone— 3 tests: parsed return value, PATCH command withstate=closed, error pathcreateRelease— 7 tests: raw string return, base command,--notes,--draft,--prerelease, false opts omission, error pathcreateProject— 3 tests:{number, url}extraction, command shape, error pathaddItemToProject— 3 tests: raw string return, command shape, error pathpostMilestoneStartAnnouncement— 9 tests: Discussion success, no-Announcements-category fallback, GraphQL-throws fallback, both-fail{posted:false}, no-repo no-op, boardUrl in body, "not configured" when absent, issue rows in body, em-dash for unassignedTest Plan
npm testtests 50 / pass 50 / fail 0ghCLI invocations occur (all mocked)