Skip to content

test(coverage): drive server/handlers to ≥95% - #20

Merged
mastermanas805 merged 1 commit into
masterfrom
coverage/prov-server-handlers-95
May 22, 2026
Merged

test(coverage): drive server/handlers to ≥95%#20
mastermanas805 merged 1 commit into
masterfrom
coverage/prov-server-handlers-95

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

  • internal/server: 54.8% → 98.9% statement coverage
  • internal/handlers: 94.1% → 100% statement coverage

What changed

  • Added server_coverage_test.go with dedicated-backend dispatch tests for every gRPC RPC (Provision/Deprovision/StorageBytes/Regrade) across postgres, redis, mongo, and queue.
  • Introduced a PoolClaimer interface seam (one-method, *pool.Manager still satisfies it) and a test-only SetPool so the pool-hit / pool-error / pool-miss branches in provisionPostgres/Redis/Mongo/Queue are exercisable without a real *pgxpool.Pool. Nil-pointer normalisation preserves production behaviour.
  • Added end-to-end gRPC round-trip via bufconn for Provision/Deprovision/StorageBytes plus the empty-token guard.
  • Covered remaining branches: callBackendVoid breaker-open, New() k8s + MinIO + dedicated-DSN constructors, teamIDFromContext via metadata, PostgresBackend/Breakers accessors, mapError invalid-arg path, pool-token-marker stripping in regradeRedis.
  • Handlers: added the >80-char error truncation test on platformDBCheck and a whitebox test for the defensive h.pool == nil branch.

Test plan

  • make gate green locally
  • Joint go test ./internal/server ./internal/handlers -coverprofile=… reports ≥95% on each
  • go test ./... green across all packages
  • No production behaviour change — the *pool.ManagerPoolClaimer switch normalises nil pointers to nil interfaces in NewWithBackends

🤖 Generated with Claude Code

- server: 54.8% → 98.9%. Adds dedicated-backend dispatch tests for every
  RPC (Provision/Deprovision/StorageBytes/Regrade) across postgres, redis,
  mongo, and queue; pool-hit / pool-error / pool-miss branches via a new
  PoolClaimer interface seam; callBackendVoid breaker-open path;
  end-to-end gRPC round-trip via bufconn; New() constructor branches for
  k8s + MinIO + dedicated DSN configs; teamIDFromContext via metadata;
  PostgresBackend / Breakers accessors.
- handlers: 94.1% → 100%. Adds long-error-message truncation path on
  platformDBCheck and a whitebox test for the defensive nil-pool branch.
- Minor refactor in server.go: typed *pool.Manager field becomes a
  PoolClaimer interface so tests can inject a fake claimer without
  standing up a real *pgxpool.Pool. Production behaviour preserved by
  normalising nil *pool.Manager to a nil interface in NewWithBackends.

Joint coverage now well above the 95% gate on both packages.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805
mastermanas805 merged commit beba68a into master May 22, 2026
10 checks passed
@mastermanas805
mastermanas805 deleted the coverage/prov-server-handlers-95 branch May 22, 2026 01:29
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