Skip to content

feat: add testcontainers Postgres integration tests#272

Merged
ajianaz merged 4 commits into
developfrom
feat/testcontainers-postgres-ci
Jun 27, 2026
Merged

feat: add testcontainers Postgres integration tests#272
ajianaz merged 4 commits into
developfrom
feat/testcontainers-postgres-ci

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Problem

CI only tested SQLite. Postgres — advertised as a core feature — was never tested end-to-end. Bugs like #213 and #209 only surfaced in production.

Solution

  • testcontainers v0.24 dev-dependency (rustc 1.85 compatible)
  • 11 integration tests — runs the full shared test suite against postgres:17-alpine via Docker
  • CI job test-postgres in ci.yml
  • Graceful skip — tests auto-skip if Docker unavailable (local dev)

Local dev

# Tests auto-skip without Docker (no setup needed)
cargo test --workspace

# Run Postgres tests explicitly (requires Docker)
cargo test -p trapfall_db --features postgres --test testcontainers_postgres

Closes #222

ajianaz added 4 commits June 27, 2026 17:40
- testcontainers v0.24 (compatible with rustc 1.85)
- Auto-spins postgres:17-alpine container
- Runs full shared test suite (11 tests) against live Postgres
- Graceful skip when Docker not available (local dev)
- test-postgres CI job in ci.yml

Acceptance criteria:
- testcontainers dev-dependency added
- 11 integration tests (same as shared suite)
- CI job for Postgres tests
- Local dev unaffected (tests skip if no Docker)

Closes #222
- trapfalld default features: postgres -> sqlite (Postgres is opt-in)
- TC tests: Result-based setup with retry_connect (10x 2s backoff)
- TC tests: graceful skip on any error (no panics)
- TC tests: no longer run in cargo test --workspace (sqlite default)
- migrate.rs: cfg-gate serde_json::Value import (postgres-only)

Root cause of CI failure: trapfalld default=["postgres"] caused tc tests
to compile and run in regular cargo test --workspace, where Docker
connection failed.
tokio-tar is a transitive dependency of testcontainers (dev-only).
No fix available. Same treatment as RUSTSEC-2023-0071.
@ajianaz ajianaz merged commit a0af47f into develop Jun 27, 2026
12 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.

test(db): add live Postgres integration test via testcontainers

1 participant