Skip to content

feat(db): shared test suite + migration tool (Phase 4 & 5)#192

Merged
ajianaz merged 2 commits into
developfrom
feat/shared-test-suite-169
Jun 15, 2026
Merged

feat(db): shared test suite + migration tool (Phase 4 & 5)#192
ajianaz merged 2 commits into
developfrom
feat/shared-test-suite-169

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the Multi-Backend Database epic (#171) — Phase 4 and Phase 5.

Closes #169, closes #170.

Phase 4: Shared Test Suite (#169)

Backend-agnostic tests that run identically against SQLite and Postgres:

Test Operations
project_crud Create, read (slug/id/dsn), update, rotate, archive, delete
issue_upsert_dedup Fingerprint dedup, count increment, status, list filtered
event_operations Insert, list, pagination, raw fetch
auth_and_sessions User CRUD, session lifecycle, expiry cleanup
auth_attempts Brute-force tracking, email + IP counting
alert_rules CRUD, toggle, history, cooldown
search LIKE/ILIKE, level filter, count
retention Purge old events, orphan cleanup
count_table Whitelist validation
ping Health check
  • SQLite: 11/11 tests pass (in-memory)
  • Postgres: compiles clean, gated behind TEST_POSTGRES_URL

Phase 5: Migration Tool (#170)

# Export SQLite → JSONL
trapfall db export --from sqlite:trapfall.db --to dump.jsonl

# Import JSONL → Postgres
trapfall db import --from dump.jsonl --to postgres://user@host/db

# Verify
trapfall db verify --url postgres://user@host/db
  • trapfalld/src/migrate.rs — export/import/verify logic
  • CLI: Db { Export, Import, Verify } subcommands
  • docs/guide/migration.md — step-by-step guide

Test Plan

  • cargo fmt --check — clean
  • cargo clippy --all-targets -- -D warnings — zero warnings
  • cargo test --workspace — all pass
  • SQLite shared tests: 11/11 pass
  • Postgres shared tests: compile clean (need live DB to run)

Epic #171 Status

Phase Issue Status
1 — Trait abstraction #186 ✅ Merged
2 — Connection factory #167 ✅ Merged
3 — Postgres backend #168 ✅ Merged
4 — Shared test suite #169 This PR
5 — Migration tool #170 This PR

ajianaz added 2 commits June 16, 2026 01:31
…169)

- Add tests/common.rs: 10 shared test functions covering all major ops
  - project_crud (create, read, update, rotate, archive, delete)
  - issue_upsert_dedup (fingerprint dedup, count increment, status)
  - event_operations (insert, list, pagination, raw fetch)
  - auth_and_sessions (user CRUD, session lifecycle, expiry cleanup)
  - auth_attempts (brute-force tracking, email + IP counting)
  - alert_rules (CRUD, toggle, history, cooldown)
  - search (LIKE/ILIKE, level filter, count)
  - retention (purge, orphan cleanup)
  - count_table (whitelist validation)
  - ping (health check)
- Add tests/sqlite_backend.rs: runs all shared tests on in-memory SQLite
- Add tests/postgres_backend.rs: runs all shared tests on live Postgres
  (skipped if TEST_POSTGRES_URL not set)
- SQLite: 11/11 tests pass
- Postgres: compiles clean, tests gated behind env var

Closes #169
…est suite (Phase 4, #169)

Phase 4 — Shared test suite (#169):
- tests/common.rs: 10 backend-agnostic test functions
- tests/sqlite_backend.rs: 11/11 pass on in-memory SQLite
- tests/postgres_backend.rs: gated behind TEST_POSTGRES_URL

Phase 5 — Migration tool (#170):
- trapfalld/src/migrate.rs: export/import/verify commands
- CLI: trapfall db export/import/verify subcommands
- docs/guide/migration.md: step-by-step migration guide
- VitePress sidebar updated

Closes #169, closes #170
@ajianaz ajianaz merged commit 5cd296b into develop Jun 15, 2026
10 checks passed
@ajianaz ajianaz deleted the feat/shared-test-suite-169 branch June 15, 2026 18:42
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.

feat(db): SQLite → Postgres migration tool (Phase 5) test(db): shared test suite for SQLite + Postgres backends (Phase 4)

1 participant