Skip to content

test: setup integration test infrastructure and persistence typing#10

Merged
heitorrsdev merged 6 commits intomainfrom
test/reservation-invariants
Feb 23, 2026
Merged

test: setup integration test infrastructure and persistence typing#10
heitorrsdev merged 6 commits intomainfrom
test/reservation-invariants

Conversation

@heitorrsdev
Copy link
Owner

Description

This PR introduces the foundational integration testing infrastructure and strengthens the persistence layer with typed database access and structured PostgreSQL error mapping.

It establishes a deterministic PostgreSQL test environment, adds domain-level integration tests for reservations, and improves repository safety and ergonomics via Drizzle schema injection and centralized database error translation.


What was done

  • Added isolated PostgreSQL Docker environment for integration tests
  • Implemented Jest bootstrap and deterministic test database lifecycle (reset/migrate/truncate)
  • Integrated test workflows into Makefile and CI pipeline
  • Added user and barber test factories for database seeding
  • Injected Drizzle schemas into the database provider for full TypeScript typing
  • Added PostgresErrorMapper to translate DB errors into domain errors
  • Added findById method to Reservation repository
  • Implemented integration tests for reservation invariants (persistence + conflict constraint)

Why

  • To enable real integration testing against PostgreSQL with deterministic state
  • To ensure domain invariants (reservation conflicts) are enforced at the database layer
  • To improve repository DX and type safety with Drizzle schema injection
  • To centralize database error translation and keep repositories clean
  • To enforce automated test execution in CI and local workflows

Notes

  • This PR focuses on infrastructure and the first integration test suite, not full domain test coverage
  • Concurrency tests for reservation conflicts will be added in a follow-up PR
  • testing.md documentation will be introduced separately to keep this PR focused

chore: remove comment in Jest config

chore: fix sourceType in ESLint config

chore: remove path aliases from Jest bootstrap in infrastructure and test layers

chore: add test alias to tsconfig

chore: add test path alias to Jest config

chore: mark test target as phony in Makefile

fix: remove test migration step in favor of Makefile migrate target

chore: add test-reset and test-migrate Makefile targets to ci-test pipeline

chore: add test database truncation script
…access

chore: export ReservationRow type in reservation mapper

chore: use Database type instead of DrizzleDatabase in Drizzle repositories

docs: add ADR documenting Drizzle schema injection in database provider

chore: wire Drizzle schemas into database provider
fix: correct PostgreSQL unique violation error code mapping

docs: add ADR for PostgreSQL error mapper

chore: fix capitalization in ADR table in README

feat: add PostgreSQL error mapper

chore: fix ADR name in README table
@heitorrsdev heitorrsdev merged commit 6316246 into main Feb 23, 2026
1 check passed
@heitorrsdev heitorrsdev deleted the test/reservation-invariants branch February 23, 2026 18:08
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.

1 participant