Add a Postgres integration test tier for repository.pg.js #36

Open
opened 2026-07-17 03:08:01 +00:00 by claude-bot · 0 comments
Contributor

All backend tests run on createMemoryRepository; no test touches repository.pg.js, so the transaction/locking/SQL layer (409 conflict path in saveCurrentAppState, claimDueCalculationJob SKIP LOCKED, unnest bulk insert, jsonbParam null-byte stripping, retention SQL) ships unverified — the June JSONB incidents were this class of bug. Add backend/test/pg/*.test.js gated on DATABASE_URL, and a CI job with a postgres:16-alpine service that runs migrations then the suite. Cover at minimum: app-state save + expectedSnapshotId conflict, job claim under concurrency, bulk usage insert + dedup constraint, calculation result save/retention, and circuit-assignment round-trip (ties to the memory-repo parity fix).

Acceptance criteria

  • CI job runs pg suite against a service container
  • Conflict (409), SKIP LOCKED claim, bulk insert, retention covered
  • Suite skips cleanly when DATABASE_URL is unset locally

Relations: relates to #7

(Audit finding F-15, 2026-07-16 — Severity: Medium, Confidence: High)

All backend tests run on `createMemoryRepository`; no test touches `repository.pg.js`, so the transaction/locking/SQL layer (409 conflict path in `saveCurrentAppState`, `claimDueCalculationJob` SKIP LOCKED, `unnest` bulk insert, `jsonbParam` null-byte stripping, retention SQL) ships unverified — the June JSONB incidents were this class of bug. Add `backend/test/pg/*.test.js` gated on `DATABASE_URL`, and a CI job with a `postgres:16-alpine` service that runs migrations then the suite. Cover at minimum: app-state save + expectedSnapshotId conflict, job claim under concurrency, bulk usage insert + dedup constraint, calculation result save/retention, and circuit-assignment round-trip (ties to the memory-repo parity fix). **Acceptance criteria** - [ ] CI job runs pg suite against a service container - [ ] Conflict (409), SKIP LOCKED claim, bulk insert, retention covered - [ ] Suite skips cleanly when DATABASE_URL is unset locally **Relations:** relates to #7 *(Audit finding F-15, 2026-07-16 — Severity: Medium, Confidence: High)*
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/BatteryStorageCalculator#36
No description provided.