test(router): drive internal/router to 95.8% coverage#141
Merged
Conversation
Add router_coverage_test.go that exercises router.NewWithHooks (and the thin router.New wrapper) under multiple config shapes: - T1 default dev boot (AdminPathPrefix empty, MetricsToken empty, no storage, no trusted proxies, ComputeProvider=noop) — covers public routes + /internal/set-tier registered + admin closed-by-default - T2 production boot with valid 32-char AdminPathPrefix, MetricsToken set + bearer-gated /metrics, TrustedProxyCIDRs with whitespace/commas, shared-key mode NOT allowed (fail-closed branch) - T3 shared-key storage provider boots when AllowSharedKey=true - T3b minio-admin (default) backend lifts isolationLabel to per-tenant - T4 ComputeProvider=k8s exercises k8s.NewStackProvider error branch - T5 legacy router.New wrapper - T6 /webhook/receive/:token via app.All — every HTTP method - T7 /webhooks/brevo/:secret receiver wiring - T8 ErrorHandler 404/405 mapping - T9 parseTrustedProxyCIDRs whitespace/empty edge cases - T10 ShutdownHooks.Readyz.MarkDraining flips /readyz to 503 Per-function coverage: New 100.0% NewWithHooks 95.9% isolationLabel 75.0% parseTrustedProxyCIDRs 100.0% total 95.8% Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/router/router_coverage_test.goexercisingrouter.NewWithHooks(and the thinrouter.Newwrapper) under multiple config shapes against a real test DB + Redis.New100% /NewWithHooks95.9% /isolationLabel75% /parseTrustedProxyCIDRs100%.Test plan
go test ./internal/router -count=1passes with all 13 specs green.go vet ./internal/routerclean.go build ./...clean.healthz_test.go,livez_test.go,error_envelope_test.go,status_public_test.go,dpop_wiring_test.go,admin_path_prefix_test.go) untouched.🤖 Generated with Claude Code