Testing
Run locally
# Docker stack (Postgres + pg_partman + pgTAP) make db pnpm migrate pnpm test # Vitest unit + integration pnpm test:db # pgTAP suite (12 assertions) # Full end-to-end pnpm test:e2e # Vitest integration (proxies through live DB)
80/20 philosophy
The highest-value test is the consistency invariant: materialized == projected. The reconcile_diff(view) function counts symmetric-difference rows between a full re-projection and the current target. Zero drift = the engine is correct.
-- Run this after every migration / bootstrap: SELECT * FROM synctable.reconcile_all(); -- Expected: all rows show drift = 0
Coverage map
| Test | Bug class |
|---|---|
| Bootstrap consistency | Post-migration drift, missing projector |
| Watched-enqueue | Column gate misses change, false-positive enqueue |
| No-op suppression | Outbox emission loop, wasted refresh cycles |
| Delete path | Tombstone missing, hard-delete vs soft-delete |
| DAG propagation | Stale children after parent refresh |
| Cycle detection | Infinite loop on registration |
| Fuzz 500 ops | Race conditions, concurrent drift |
| Dead-letter liveness | Poison key blocks pipeline |
Production drift alarm
SELECT cron.schedule('synctable-drift', '*/15 * * * *',
$SELECT CASE WHEN sum(drift) > 0
THEN pg_catalog.raise('drift detected')
ELSE 0
END FROM synctable.reconcile_all()$);