test(coverage): drive sdk-go to >=95% coverage#12
Merged
Conversation
- Refactor examples/agent-bootstrap + examples/provision-all main() to extract a testable Run(ctx, client) function; thin main() wraps it - Add main_test.go for each example with httptest mock server - Cover all error branches in instant/deploy.go + instant/storage.go + cache.go + mongodb.go + queue.go + webhook.go + resources.go + claim.go via a new instant/coverage_test.go Coverage: 59.4% -> 97.8%. Per user mandate "95% without exception": - examples/agent-bootstrap 98.9% - examples/provision-all 98.6% - instant/ 97.3% 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
examples/agent-bootstrap/main.go+examples/provision-all/main.goto extract a testableRun(ctx, client) errorfunction;main()stays as a thin wrapper.main_test.gofor each example with anhttptest-backed mock api server covering happy + error branches.instant/coverage_test.gocovering every error-return branch indeploy.go(5xx, decode failure, transport error, tarball read failure, nil writer, SSE write error),storage.go,cache.go,mongodb.go,queue.go,webhook.go,resources.go, andclaim.go.Coverage
examples/agent-bootstrap98.9%examples/provision-all98.6%instant/97.3%Per user mandate "95% across all repos without any exception" — no codecov ignores; the examples are actually exercised end-to-end against an httptest server.
Test plan
go test ./... -short -coverprofile=coverage.out -covermode=atomic— green, 97.8% totalgo test ./... -race -count=1 -short— greengo vet ./...+go build ./...— greeninstant.Clientmethods untouched)Refactor rationale: extracting
Run(ctx, client, ...)frommain()is the industry-standard pattern for testing executable examples — not coverage theatre. The newRunfunction can be called from a documentation example, a sibling tool, or a different runtime without changing behaviour.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com