You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CI hanya menjalankan cargo test --workspace dengan SQLite sebagai backend live. Path Postgres — yang diiklankan sebagai fitur core sejak v0.1.2 — tidak pernah diuji end-to-end di CI.
Bukti:
.github/workflows/ci.yml tidak punya service postgres block.
Tidak ada testcontainers dev-dependency di crates/trapfall-db/Cargo.toml.
Semua integration test pakai sqlite::open(":memory:") atau file temp.
Prioritas: medium-high. TrapFall mengiklankan Postgres sebagai backend utama (sanding SQLite). Tidak punya integration test untuk itu adalah blind spot.
Pertimbangan image size: postgres:16-alpine ~80MB, pull cepat di GHA runner. Tidak akan memperlambat CI signifikan (<1 menit untuk full suite).
Out of scope: SQLite integration test (sudah implicit lewat unit tests yang pakai :memory:).
Out of scope: performance benchmark Postgres vs SQLite.
Problem
CI hanya menjalankan
cargo test --workspacedengan SQLite sebagai backend live. Path Postgres — yang diiklankan sebagai fitur core sejak v0.1.2 — tidak pernah diuji end-to-end di CI.Bukti:
.github/workflows/ci.ymltidak punya servicepostgresblock.testcontainersdev-dependency dicrates/trapfall-db/Cargo.toml.sqlite::open(":memory:")atau file temp.Ini sudah dua kali bikin masalah:
main.rscrash saat startup denganpostgres://karena always-callsqlite_pool(). Bug ini hanya terlihat saat user coba pakai Postgres di production, tidak ketahuan di CI. Fix ada di PR fix: postgres startup + DSN leak + MCP schema sync + minor cleanups #217, tapi regression serupa bisa terjadi lagi tanpa guard.Saat ini paritas SQLite ↔ Postgres hanya di-guard oleh unit test shared (issue #169) yang mock kedua backend via trait, bukan test SQL sungguhan.
Proposed solution
Pakai
testcontainerscrate untuk spin up Postgres container ephemeral di setiap test run yang butuh live DB.Arsitektur
```
crates/trapfall-db/
tests/
common/mod.rs ← helper: async fn spawn_postgres() -> (Container, Database)
postgres_integration.rs ← test yang hanya jalan kalau TEST_POSTGRES=1 (atau selalu, kalau container tersedia)
```
Test yang perlu ada:
run_postgres_migrations()di container baru → verifikasi semua tabel + index + constraint created identik dengan SQLite.delete_projectgagal di tengah → verify no orphaned rows (regression test untuk fix(db): wrap delete_project in transaction + atomic upsert_issue #209).CI setup
Tambah job baru di
.github/workflows/ci.yml:```yaml
test-postgres:
name: Test (Postgres via testcontainers)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run Postgres integration tests
run: cargo test --features trapfall_db/postgres --test postgres_integration
```
testcontainersakan pull imagepostgres:16-alpineotomatis (Docker sudah tersedia di GitHub Actions runner).Acceptance criteria
testcontainersdev-dependency ditambahkan kecrates/trapfall-db/Cargo.toml.test-postgresbaru di CI, required check untuk PR kedevelop.--lib(tidak wajib Docker untuk developer yang cuma kerja SQLite path).Notes
postgres:16-alpine~80MB, pull cepat di GHA runner. Tidak akan memperlambat CI signifikan (<1 menit untuk full suite).:memory:).