Skip to content

test(coverage): drive api root + telemetry to ≥95%#158

Open
mastermanas805 wants to merge 1 commit into
masterfrom
coverage/api-root-telemetry-95b
Open

test(coverage): drive api root + telemetry to ≥95%#158
mastermanas805 wants to merge 1 commit into
masterfrom
coverage/api-root-telemetry-95b

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Extract main()'s body into a behavior-preserving run() seam (error-returning) with package-level function vars over every external boundary (Postgres / Redis / GeoIP / provisioner / router / serve). Boot→ready→teardown plus migrations-fail, plans-load-fail (prod), provisioner-connect-fail, and serve-error arms are now unit-testable without real infra or a bound listener. main() becomes a thin runFunc/osExit wrapper.
  • Add newExporter/newResource package-var seams in internal/telemetry to reach the two otlptracegrpc.New / resource.New constructor-failure arms.
  • Production wiring is identical — seam vars default to the real implementations; the P0-2 OTel TLS-by-scheme + NR api-key contract is untouched and its tests stay green.

Coverage

  • root instant.dev: 30.2% → 98.2%
  • internal/telemetry: 85.7% → 98.3%
  • go tool cover -func | awk '$3+0<95' → empty (no function below 95%)

Test plan

  • go build ./... + go vet ./... clean
  • go test . ./internal/telemetry -coverprofile -count=1 -p 1 — both ≥95%, all green
  • OTel P0-2 contract tests (TestShouldUseTLS / TestInitTracer_WithLicenseKey / TestInitTracer_Boots) pass
  • Existing graceful-shutdown MR-P0-7 tests pass

🤖 Generated with Claude Code

…rving seams

Extract main()'s body into a run() error-returning seam with package-level
function vars over every external boundary (Postgres/Redis/GeoIP/provisioner/
router/serve) so boot → ready → teardown plus the migrations-fail, plans-load-
fail, provisioner-connect-fail, and serve-error arms are unit-testable without
real infra or a bound listener. main() becomes a thin runFunc/osExit wrapper.
Add newExporter/newResource package-var seams in telemetry to reach the two
otlptracegrpc.New/resource.New constructor-failure arms. Production wiring is
identical — the seam vars default to the real implementations and the P0-2
OTel TLS-by-scheme + NR-api-key contract is unchanged.

Root 30.2% → 98.2%, telemetry 85.7% → 98.3%; no function below 95%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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