Skip to content

test(coverage): db runner + straggler packages to ≥95%#146

Merged
mastermanas805 merged 2 commits into
masterfrom
coverage/api-db-stragglers-95
May 22, 2026
Merged

test(coverage): db runner + straggler packages to ≥95%#146
mastermanas805 merged 2 commits into
masterfrom
coverage/api-db-stragglers-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

Drives internal/db (migration runner) and the remaining sub-95% api
support packages to ≥95% statement coverage. Scoped to DB-runner +
stragglers only (handlers/models/middleware/crypto/providers/plans/
tokens/quota/config/metrics/provisioner/razorpaybilling are owned by
sibling agents and untouched here).

package before after
internal/db (rebased #139 work) 95.7%
internal/cliconfig 70.0% 97.5%
internal/experiments 88.5% 100%
internal/circuit 92.3% 100%
internal/cache 85.3% 97.1%
internal/email 82.3% 97.0%
internal/telemetry 80.4% 85.7% (capped)

internal/telemetry cannot reach 95% without modifying production
tracer.go: the two uncovered branches are otlptracegrpc.New /
resource.New constructor failures, which dial lazily and never error
with valid arguments. There is no injection seam, and the file carries
an explicit P0-2 "do not revert" note — adding a test seam was judged
out of scope / higher-risk than the 6 uncovered statements.

This branch includes the rebased internal/db commit from #139 (rebased
onto current master so the up-to-date-with-base gate is green). If #139
merges first, this can be re-targeted; otherwise this supersedes it.

Test-only changes — no production code modified.

Test plan

  • go build ./... + go vet ./... clean
  • All 7 owned packages pass -short -count=1 -p 1 against the test DB
  • Per-package -coverprofile confirms the table above
  • CI coverage gate green

Note: a pre-existing flake in internal/models
(TestCreateStackWithCap_ConcurrentRaceCannotBypassCap) is unrelated to
this PR — that package is untouched here and the test fails identically
on a clean checkout.

🤖 Generated with Claude Code

mastermanas805 and others added 2 commits May 22, 2026 07:33
…pers

Covers the platform-DB boot gate: migration apply + idempotency, schema
version tracking via schema_migrations rows + applied_at preservation,
record-failed warn branch (via view-masking the table), connect-helper
panic paths (bad DSN + unreachable host), Err{DB,Redis}Connect Error +
Unwrap, ConnectRedis happy path, and the ticker.C branch of the pool
stats exporter.

Coverage: 35.1% → 95.7% (rule-22 enumeration: 13 functions, 13 touched;
remaining 4.3% is defensive if-err blocks on embed.FS reads which
provably never fail on a compiled-in directory).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds focused tests for the sub-95% api support packages not owned by
sibling coverage agents:

  cliconfig    70.0% → 97.5%  (configPath/Load/Save/Clear error branches)
  experiments  88.5% → 100%   (register panics + empty-variant guard)
  circuit      92.3% → 100%   (NewBreaker clamps, all State() branches, Name)
  cache        85.3% → 97.1%  (SET marshal-fail, type-mismatch, Invalidate err)
  email        82.3% → 97.0%  (breaker ctor/ProviderName/keyless wrappers;
                               resolveProvider, sendWithKey ledger+suppression
                               fail-open, brevo/resend provider Send paths,
                               maskEmail edges)
  telemetry    80.4% → 85.7%  (OTEL_SERVICE_NAME override, TLS/insecure,
                               license-key header, sentinel-key paths)

telemetry's remaining gap is two genuinely untriggerable defensive
branches (otlptracegrpc.New / resource.New constructor failures — both
dial lazily and never error with valid args; no injection seam exists,
and tracer.go carries an explicit "do not revert" P0-2 note). All other
owned packages clear the 95% bar. Test-only changes; no production code
touched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 6d9c740 into master May 22, 2026
11 checks passed
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