-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
backendphase:32-test-coveragePhase 32: Test CoveragePhase 32: Test CoveragetestingTest coverageTest coverage
Milestone
Description
Context
Phase 32 — Test Coverage. lib/github.cjs is the GitHub API boundary — all issue reads, milestone operations, PR creation, and rate limit queries flow through it. All functions wrap execSync via an internal run() helper; untested means any gh CLI interface change or flag typo silently breaks the pipeline. Mocking execSync is the only way to test without hitting real GitHub API.
What Already Exists
lib/github.cjs(272 lines) — exports: getRepo, getIssue, listIssues, getMilestone, getRateLimit, closeMilestone, createRelease, createProject, addItemToProject, postMilestoneStartAnnouncement- Internal
run(cmd)helper (line 18) calls execSync with stdio piped — this is what must be mocked test/mgw.test.cjs(75 lines) — placeholder; documents node:test + node:assert/strict pattern; npm test wiredpackage.jsontest script:node --test 'test/**/*.test.cjs'- github.cjs uses
const { execSync } = require('child_process')at module scope — must use module cache invalidation trick for mocking
Description
Implement unit tests for lib/github.cjs using node:test built-in runner. All functions wrap execSync via the internal run() helper — mock via module cache invalidation trick.
Technical Approach
- New file:
test/github.test.cjs - Mock pattern:
delete require.cache[require.resolve('../lib/github.cjs')]in beforeEach, thenmock.method(childProcess, 'execSync', () => fixture), then re-require github.cjs so it picks up the mock - Fixtures: pre-baked JSON strings matching gh CLI output shapes for issue, milestone, rate_limit, repo nameWithOwner
- Test each function: verify correct gh CLI command is constructed AND return value is correctly parsed
- Error path: verify execSync throw propagates as Error from each function
Done When
-
test/github.test.cjsexists with test cases for all 10 exported functions - execSync is mocked via module cache invalidation in beforeEach — no real gh CLI calls made during tests
- getIssue, listIssues, getMilestone, getRateLimit tests verify both correct command construction and return value parsing
- At least one test per function covers the error path (execSync throws → function throws)
-
npm testexits 0 with all tests passing
GSD Route
Quick task (mgw:run → quick path). Single plan, single executor.
Phase Context
Phase 32 of 36 — Test Coverage. Runs independently. Issues: #133, #134 (this).
Depends on
Nothing — runs independently alongside #133.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backendphase:32-test-coveragePhase 32: Test CoveragePhase 32: Test CoveragetestingTest coverageTest coverage