Skip to content

test: cover all of src/ and require 100% coverage from now on - #136

Merged
johnf merged 1 commit into
mainfrom
test/full-coverage
Nov 25, 2026
Merged

johnf merged 1 commit into
mainfrom
test/full-coverage

Conversation

@johnf

@johnf johnf commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Coverage of src/ was 98.9% statements / 96.4% branches. It is now 100% on every measure, and the thresholds are a fixed { 100: true } instead of auto-raised.

The gap was mostly real behaviour with no test, not lines needing contrived tests.

Newly tested

  • Signing a user with a session in again without the upstream provider, reusing the grant and adding scopes they ask for
  • Refusing tokens for a resource other than the API (invalid_target)
  • Sign-in page refused to a browser that didn't start it, or once its upstream checks expired; upstream callback with no state
  • Signing out with no session
  • Storage failing inside the provider: a 500, and the provider's error logged
  • Hourly cleanup of expired provider state, and logging when it fails
  • Restricted content withheld while REMS fails
  • An unexpected error checking a bearer token fails the request instead of serving it anonymously
  • Admin sign-in failing at the callback; an admin with no name shown by their sub
  • Claims left out for a user with no name
  • Crates sharing a label ordered by id; an entity listed twice in a page gets its aggregates both times

Removed rather than tested

  • Guards that only satisfied the types: the grant lookup (oidc-provider only calls it with a client and an account), the upstream ID token (idTokenExpected already rejects a response without one, now tested), the first cookie key (config requires one; typed as non-empty), the API prefix
  • The admin sign-in fetch's handling of requests it never makes (only the token POST goes through it)
  • The logger's pretty-printing choice is now a function, so the fallback when pino-pretty isn't installed is testable

One /* v8 ignore */ remains, with its reason: the no-op handler Fastify requires on the routes that handOff answers in onRequest.

CLAUDE.md now says how to stay at 100% without writing tests just to reach lines.

@johnf
johnf marked this pull request as ready for review November 25, 2026 01:07
Test what was untested: signing in again with a live session (reusing and widening the grant),
refusing tokens for a resource other than the API, the sign-in page and callback error paths,
signing out with no session, storage failures inside the provider, the hourly cleanup of expired
provider state, REMS failing, an unexpected error while checking a bearer token, admin sign-in
failing at the callback, nameless users, crates sharing a label, and an entity listed twice in a
page.

Remove what no test could reach: guards that only satisfied the types (the grant lookup, the
upstream ID token, the first cookie key, the prefix) and the admin sign-in fetch's handling of
requests it never makes. The logger's pretty-printing choice becomes a function so its fallback
is testable.

Thresholds are now a fixed 100% rather than auto-raised, and CLAUDE.md says how to keep it there
without writing tests for coverage's sake.
@johnf
johnf force-pushed the test/full-coverage branch from 2c3dda5 to 67ff055 Compare November 25, 2026 01:12
@johnf
johnf merged commit 16b74a2 into main Nov 25, 2026
5 checks passed
@johnf
johnf deleted the test/full-coverage branch November 25, 2026 01:19
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