Skip to content

test: add unit coverage for comment helpers, token, git-config, and createInitialComment#1414

Open
mateuscmtropical wants to merge 2 commits into
anthropics:mainfrom
mateuscmtropical:test/github-coverage-batch-2
Open

test: add unit coverage for comment helpers, token, git-config, and createInitialComment#1414
mateuscmtropical wants to merge 2 commits into
anthropics:mainfrom
mateuscmtropical:test/github-coverage-batch-2

Conversation

@mateuscmtropical

@mateuscmtropical mateuscmtropical commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1404. Adds unit tests for two more under-tested files in src/github, both previously at low coverage. Tests only — no source changes.

File Coverage before After New tests
operations/comments/common.ts 20% lines 100% 7
token.ts 20% funcs 100% 15

Notes

  • The comment-formatting helpers are pure; tested with equivalence partitioning / boundary values.
  • token.ts (the OIDC → GitHub App token exchange) is IO-bound: tested with spyOn on core.getIDToken and global fetch, reusing test/mockContext.ts. The retry waits are mocked out so failure-path tests don't sleep.

Validation

$ bun test --coverage  (2 new files)

File                                      | % Funcs | % Lines
------------------------------------------|---------|--------
 src/github/operations/comments/common.ts |  100.00 |  100.00
 src/github/token.ts                       |  100.00 |  100.00

 22 pass   0 fail
   comments-common.test.ts  ->   7 pass
   github-token.test.ts     ->  15 pass

$ bun run typecheck  -> OK

Mutation testing (StrykerJS)

File        | Mutants | Killed | Survived | Score
------------+---------+--------+----------+--------
 common.ts  |   10    |   10   |    0     | 100.00%
 token.ts   |   107   |  101   |    6     |  94.39%

The 6 token survivors are all equivalent mutants (redundant trim() calls masked by a later check, and optional chaining on values that are never null at that point). No behavioral survivors.

🤖 Generated with Claude Code

Covers createJobRunLink, createBranchLink, createCommentBody and the
SPINNER_HTML constant in src/github/operations/comments/common.ts,
which previously sat at 20% line coverage. Verifies the markdown link
formats, the default empty branch link, and the assembled comment
body. Mutation score (StrykerJS): 100%.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mateuscmtropical mateuscmtropical force-pushed the test/github-coverage-batch-2 branch from 194e215 to a09a212 Compare June 14, 2026 18:30
setupGitHubToken and getOidcToken had no tests (23.7% line coverage
for src/github/token.ts). Covers the override token short-circuit,
the OIDC to app token exchange (headers, merged permissions body,
token/app_token response fields), retry exhaustion on missing token
and non-ok responses, the OIDC failure guidance message, and the
workflow validation skip path that must not retry. Also adds boundary
cases for parseAdditionalPermissions (empty key, empty value, no
valid lines). The retry helper is module-mocked with the same
semantics minus the backoff sleeps so failure paths run instantly.

Mutation score (StrykerJS): 83.2%; every surviving mutant is either a
console log string or an equivalent mutant (redundant trims and
optional chaining on never-null objects).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mateuscmtropical mateuscmtropical force-pushed the test/github-coverage-batch-2 branch from a09a212 to 24436db Compare June 14, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant