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

TestBug class
Bootstrap consistencyPost-migration drift, missing projector
Watched-enqueueColumn gate misses change, false-positive enqueue
No-op suppressionOutbox emission loop, wasted refresh cycles
Delete pathTombstone missing, hard-delete vs soft-delete
DAG propagationStale children after parent refresh
Cycle detectionInfinite loop on registration
Fuzz 500 opsRace conditions, concurrent drift
Dead-letter livenessPoison 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()$);