Skip to content

test(coverage): drive resource-provisioning handlers 45% -> 75%#145

Merged
mastermanas805 merged 2 commits into
masterfrom
coverage/api-handlers-resource-95
May 22, 2026
Merged

test(coverage): drive resource-provisioning handlers 45% -> 75%#145
mastermanas805 merged 2 commits into
masterfrom
coverage/api-handlers-resource-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Adds integration + unit tests for the resource-provisioning handler files (resource.go, resource_metrics.go, resource_family.go, db.go, cache.go, nosql.go, queue.go, storage.go, webhook.go), raising aggregate statement coverage on these files from 45.1% to 74.6%.
  • New files: coverage_resource_extra_test.go (MinIO-backed storage provisioning + full metrics tier matrix), coverage_resource_backend_test.go (full-backend pause/resume/rotate/twin/negative-path flows), coverage_resource_unit_test.go (package-internal decrypt/credentials/metrics helpers), plus resumed partial work in coverage_resource_pure_test.go / coverage_resource_files_test.go.
  • Renamed existing twin / metrics / body-validation tests so they run under the coverage gate's -run filter.

Per-file coverage (after)

file coverage
resource_metrics.go 92.5%
resource_family.go 78.3%
nosql.go 75.8%
resource.go 75.8%
webhook.go 75.7%
queue.go 73.3%
db.go 71.2%
storage.go 70.0%
cache.go 69.7%

Note on the 95% target

The task target was >=95%. The residual uncovered code is dominated by (a) the gRPC provisioner-client arms (provisionDB/Cache/NoSQL/Queue, the provClient != nil branch) and (b) DB / encrypt fault-injection error branches. The handlers take a concrete *provisioner.Client with unexported fields and no DI seam, so these paths are not reachable from handlers_test without a bufconn gRPC server / handler refactor — out of scope for a test-only change.

Test plan

  • go build ./... + go vet ./... clean
  • Full go test ./internal/handlers suite passes (no regressions from renames)
  • Target -run filter suite green with backends (pg/redis/mongo/minio) up; skips cleanly when a backend is absent

🤖 Generated with Claude Code

mastermanas805 and others added 2 commits May 22, 2026 07:28
Adds black-box + white-box tests for the resource-provisioning handler
files (resource.go, resource_metrics.go, resource_family.go, db.go,
cache.go, nosql.go, queue.go, storage.go, webhook.go):

- coverage_resource_extra_test.go: MinIO-backed credential-mode storage
  provisioning (anon + authed + quota + dedup), full resource_metrics.go
  tier-gate matrix (92.5%), postgres rotate.
- coverage_resource_backend_test.go: full-backend lifecycle flows
  (provision -> getcredentials -> rotate -> pause -> resume -> delete) for
  postgres/redis/mongo against the local Docker backends, twin paths, and
  per-handler negative paths (bad body / missing name / bad env / 415).
- coverage_resource_unit_test.go: package-internal helpers
  (decryptConnectionURL fail-closed, decryptWebhookURL fail-open,
  storeEncryptedURL, addQueueCredentials, metrics tier-cap helpers,
  anonymous-limits builders).
- coverage_resource_pure_test.go / coverage_resource_files_test.go:
  resumed partial work (pure helpers, authed provision, presign, delete,
  pause/resume, dedup branches).
- Renamed existing twin / metrics / body-validation tests to match the
  resource test-name prefixes so they run under the coverage gate filter.

Target was >=95%; the residual gap is the gRPC provisioner-client arms
(provisionDB/Cache/NoSQL/Queue) and DB/encrypt fault-injection branches,
which the handlers' public constructors expose no seam to exercise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TestQueueNew_Authenticated_Pro (resumed partial work) asserted 201
unconditionally; CI has no NATS backend so /queue/new returns 503.
Add the skipIfProvisionResp guard used by the sibling provision tests so
the suite skips rather than fails when the queue backend is unreachable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 5503159 into master May 22, 2026
11 checks passed
@mastermanas805 mastermanas805 deleted the coverage/api-handlers-resource-95 branch May 22, 2026 02:13
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