Skip to content

test(coverage): drive sdk-go to >=95% coverage#12

Merged
mastermanas805 merged 1 commit into
masterfrom
coverage/push-to-95
May 21, 2026
Merged

test(coverage): drive sdk-go to >=95% coverage#12
mastermanas805 merged 1 commit into
masterfrom
coverage/push-to-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Refactor examples/agent-bootstrap/main.go + examples/provision-all/main.go to extract a testable Run(ctx, client) error function; main() stays as a thin wrapper.
  • Add main_test.go for each example with an httptest-backed mock api server covering happy + error branches.
  • Add instant/coverage_test.go covering every error-return branch in deploy.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, and claim.go.

Coverage

  • Before: 59.4% (instant 86.4%, examples 0%)
  • After: 97.8%
    • examples/agent-bootstrap 98.9%
    • examples/provision-all 98.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% total
  • go test ./... -race -count=1 -short — green
  • go vet ./... + go build ./... — green
  • Exported SDK API unchanged (refactor only extracts internals from main; signatures of instant.Client methods untouched)

Refactor rationale: extracting Run(ctx, client, ...) from main() is the industry-standard pattern for testing executable examples — not coverage theatre. The new Run function 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

- 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>
@mastermanas805 mastermanas805 merged commit 8a1bc2f into master May 21, 2026
9 checks passed
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