Skip to content

Add I/O function tests: 98% coverage on run.ts - #1

Merged
tbjers merged 2 commits into
mainfrom
test/phase-6-io-tests
Jun 24, 2026
Merged

Add I/O function tests: 98% coverage on run.ts#1
tbjers merged 2 commits into
mainfrom
test/phase-6-io-tests

Conversation

@tbjers

@tbjers tbjers commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Export Metric, run, runIngest, runPRCheck, postCheckRun from run.ts for testability
  • Mock @actions/core, @actions/github, fs, and fetch with vi.hoisted + vi.mock + vi.stubGlobal
  • 52 tests total (up from 31), statement coverage jumps from 22% → 98%, functions 100%
  • Covers: all early-exit paths in run(), ingest success/error, all threshold breach types, missing token, baseline errors, Check Run success/failure/fork degradation, PR head SHA selection

Test plan

  • Workflow runs on this PR and posts a Check Run (PR path end-to-end test)
  • npm test passes locally: 52/52 green
  • Coverage report shows ≥ 20% (actual ~98%) so min-coverage threshold passes
  • Check Run summary table visible on this PR with coverage and duplication metrics

🤖 Generated with Claude Code

tbjers and others added 2 commits June 24, 2026 13:54
Export Metric interface and run/runIngest/runPRCheck/postCheckRun for
testability. Mock @actions/core, @actions/github, fs, and fetch via
vi.hoisted + vi.mock + vi.stubGlobal. Tests cover all early-exit paths
in run(), ingest success/failure, all threshold breach types, missing
GITHUB_TOKEN, baseline fetch errors, Check Run success/failure/fork
degradation, and the PR head SHA selection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cloudflare Access blocks all /api/* requests before the Worker sees them,
so the OIDC-gated baseline endpoint was returning the Access login page
(<!DOCTYPE html>) instead of JSON. The fix mirrors /ingest: mount baseline
at the root level so only the Worker's own requireOidc() middleware applies.

Route changes:
- Extract baseline handler into src/routes/baseline.ts (OIDC-gated)
- Remove baseline from src/routes/api.ts (Access-gated)
- Mount at /baseline in src/index.ts alongside /ingest
- Update Action fetch URL: /api/projects/:o/:r/baseline → /baseline/:o/:r
- Update test assertion to match new URL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tbjers
tbjers merged commit 6ff2a9a into main Jun 24, 2026
4 checks passed
@tbjers
tbjers deleted the test/phase-6-io-tests branch June 24, 2026 18:24
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