test(coverage): drive api root + telemetry to ≥95%#158
Open
mastermanas805 wants to merge 1 commit into
Open
Conversation
…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>
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
main()'s body into a behavior-preservingrun()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 thinrunFunc/osExitwrapper.newExporter/newResourcepackage-var seams ininternal/telemetryto reach the twootlptracegrpc.New/resource.Newconstructor-failure arms.api-keycontract is untouched and its tests stay green.Coverage
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 ./...cleango test . ./internal/telemetry -coverprofile -count=1 -p 1— both ≥95%, all green🤖 Generated with Claude Code