test(provisioner): drive client.go to 98.1% coverage#137
Merged
Conversation
Adds bufconn-backed gRPC harness with a mock ProvisionerServiceServer + the standard gRPC health-checking service. Drives every previously-uncovered exported method: NewClient (constructor + OnOpen logger), Breaker accessor, HealthCheck (SERVING / NOT_SERVING / RPC error / nil receiver), ctxWithAuth + ctxWithTeamID (empty + set branches), provisionTimeout (every tier), ProvisionCache / ProvisionNoSQL / ProvisionQueue / StorageBytes / DeprovisionResource (success + error branches each), and the nil-breaker fast-path in callWithBreaker for every RPC wrapper. Coverage: 52.8% → 98.1% (gofunc-level: 11 of 14 functions at 100%; NewClient 83.3% because the grpc.NewClient error return is impossible to trigger from caller-side; ctxWithAuth 75% because the request-id branch requires the unexported middleware context key — exercised end-to-end in e2e/ tests). 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/provisionergRPC client to 98.1% line coverage (was 52.8%; brief target ≥95%).internal/provisioner/client_cov_test.goonly — zero production-code changes.Coverage delta (gofunc)
What the new tests do
ProvisionerServiceServer+ standardgrpc.health.v1.Healthserver.NewClientconstructor +OnOpenlogger closure (tripping the breaker).HealthCheck: SERVING / NOT_SERVING / RPC failure / nil receiver / nil conn.ctxWithAuth/ctxWithTeamID: empty + populated team-ID branches; auth header forwarded byte-for-byte.provisionTimeout: every tier (pro/team/growth → 5m; anonymous/hobby/hobby_plus/free/empty → 4m).ProvisionPostgres,ProvisionCache,ProvisionNoSQL,ProvisionQueue,StorageBytes,DeprovisionResource) tested for both success AND wrapped-error branches (usingcodes.Unavailable,Internal,Unknown,ResourceExhausted).callWithBreakerexercised via every RPC wrapper.Remaining gaps (intentional)
NewClient83.3%:grpc.NewClienterror return is not reachable from caller-side (no malformed inputs trigger it).ctxWithAuth75%: therid != ""branch requires the middleware's unexported context key — exercised end-to-end ine2e/.Test plan
go test ./internal/provisioner -coverprofile=/tmp/cov.out -count=1→ PASS, 98.1%go vet ./internal/provisioner/...→ clean🤖 Generated with Claude Code