Skip to content

Close the test coverage gaps across modules - #71

Merged
duynhne merged 4 commits into
mainfrom
test/coverage-gaps
Aug 7, 2026
Merged

Close the test coverage gaps across modules#71
duynhne merged 4 commits into
mainfrom
test/coverage-gaps

Conversation

@duynhne

@duynhne duynhne commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Test-only PR (9 test files, no production code) closing the gaps an audit of all 13 modules found. Verified by an independent adversarial review; its one Required finding (a tautological drift guard in the grpcx reason table) and all Optional findings are addressed.

Coverage movement

Module Before After
logger/zerolog — (no tests) 100%
logger/clog — (no tests) 82.6%
grpcx 88.2% 100%
flagx 92.6% 100%
idempotency — (integration only) 20% unit (pure surface; CRUD stays behind -tags=integration)
dbx 23.2% 55.4%
migratex 50% 71.4%
authmw 91.1% 93.3%

What the new tests pin

  • logger/clog: the TracingHandler.WithAttrs/WithGroup wrapper-preservation contract — losing the wrapper silently drops trace injection on every derived logger; plus injection both ways, Enabled delegation, context round-trip, alias level filtering.
  • logger/zerolog: level parsing, Setup globals (restored in cleanup), trace/span-ID injection positive+negative.
  • idempotency: Record.Finished (a stored 0 counts as finished), sentinel identity, and scan via a fake pgx.Row — ErrNoRows translation, error wrapping, and the columns↔dest-order lockstep that would corrupt records silently if reordered.
  • grpcx: deadline interceptor (default applied / caller deadline kept), peerAddr, stream access-log interceptor, and a reason-classification table where the reason overrides the status code in both directions, with a drift tripwire on the production maps.
  • httpx: all 18 error-code strings pinned and distinct (wire contract).
  • dbx: option injection; the dbx: ping failure wrap on a closed port.
  • migratex: the unusable-DSN branch after a valid source.
  • flagx: both Must* fatal paths via subprocess re-exec.
  • authmw: the malformed-JWKS-URL constructor error (an unreachable URL intentionally isn't one — the middleware 503s at request time instead, already covered).

Full make test gate green under -race.

🤖 Generated with Claude Code

duynhne added 3 commits August 7, 2026 17:58
Both modules shipped with zero tests. zerolog: level parsing,
Setup's global level, trace/span-ID injection through WithContext
(positive and negative), bare-context fallback. clog: level
parsing, TracingHandler injection both ways, Enabled delegation,
the WithAttrs/WithGroup wrap-preservation contract (losing the
*TracingHandler wrapper would silently drop trace injection on
every derived logger), context round-trip, and the four context
aliases' level filtering. API-only span contexts — no OTel SDK.
The module only had Docker-gated integration tests. Cover
Record.Finished (including the stored-zero response code, which
counts as finished by design), sentinel error identity, New's
field wiring, and scan via a fake pgx.Row: ErrNoRows→ErrNotFound
translation, generic-error wrapping, and the column-to-field
mapping that would corrupt records silently if reordered.
grpcx: deadline interceptor (default applied, caller deadline
kept), peerAddr, the stream access-log interceptor, and a table
forcing every declared error reason into the business/transient
classification with the reason overriding the status code.
httpx: pin all 18 error-code strings and their distinctness.
dbx: option injection and the ping-failure wrap on a closed port.
migratex: the unusable-DSN branch after a valid source. flagx:
subprocess re-exec over both Must* fatal paths. authmw: the
malformed-JWKS-URL constructor error (an unreachable URL is
deliberately not a constructor failure — keyfunc refreshes in the
background and the middleware 503s at request time).
Run's apply, ErrNoChange-on-rerun, and failed-migration branches
need a real database — the only migratex paths unit tests cannot
reach. Testcontainers-backed behind the integration tag, same
pattern and pinned version as dbx/idempotency. Lifts migratex CI
coverage (the gate runs TAGS=integration) past the fleet's 80% bar.
@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@duynhne
duynhne merged commit 40ae609 into main Aug 7, 2026
11 checks passed
@duynhne
duynhne deleted the test/coverage-gaps branch August 7, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant