Skip to content

test(postgres): raise backend/postgres coverage to 91.6%#22

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

test(postgres): raise backend/postgres coverage to 91.6%#22
mastermanas805 merged 1 commit into
masterfrom
coverage/prov-backend-pg-95

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Raises internal/backend/postgres statement coverage from a 18.7% baseline to 91.6%.
  • Adds live (real-Postgres) + fake-clientset + httptest coverage across all four backends.

What's covered

  • LocalBackend: Provision / StorageBytes / Deprovision / Regrade — happy path against a real cluster, plus connect-failure, duplicate-CREATE, CREATE USER collision, and privilege-denied terminal branches (DROP DATABASE / ALTER ROLE as a non-superuser "warden" role).
  • DedicatedProvider: local-admin lifecycle + error branches, Neon-mode httptest success/bad-status/bad-json/http-error.
  • K8sBackend: per-step Provision rollback (network policy → service), applyNamespace terminating-recreate + ctx-cancel, waitPodReady list-error + ctx-cancel, and initDatabase / StorageBytes / Regrade deep paths driven against a real Postgres by pointing a fake Service's ClusterIP at 127.0.0.1 and seeding the admin Secret.
  • NeonBackend: httptest success + reuse-existing + http-error.
  • NewBackend factory: k8s route-registry enablement (valid kubeconfig + REDIS_URL_FOR_ROUTES).

Remaining gap (8.4%)

Uncovered statements are defensive handlers not reachable without adding test seams to production code: conn.Close error logs, crypto/rand failures, http.NewRequest/json.Marshal construction wraps, the k8s real-pod-only route-registry block, and 3-minute pod-ready timeouts.

Test plan

  • CUSTOMER_POSTGRES_DSN=… go test ./internal/backend/postgres -count=1 — all pass, 91.6% coverage, ~21s
  • go vet ./internal/backend/postgres clean
  • gofmt -l clean on all test files

🤖 Generated with Claude Code

Add live + fake-clientset tests across the postgres provisioning backend:
LocalBackend Provision/StorageBytes/Deprovision/Regrade (happy + connect /
CREATE USER / privilege-denied error branches), DedicatedProvider local +
Neon paths, K8sBackend orchestration (per-step rollback, applyNamespace
terminating-recreate, waitPodReady error/cancel, StorageBytes/Regrade deep
paths via a fake Service pointed at a real Postgres), NeonBackend httptest
success/error paths, and the NewBackend k8s route-registry factory branch.

Remaining uncovered statements are defensive handlers not reachable without
mocking pgx/http/clientset (conn.Close error logs, crypto/rand failures,
http request-construction wraps, the k8s real-pod-only route-registry block,
and 3-minute pod-ready timeouts).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 0ed3f05 into master May 22, 2026
10 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