Pgtestdb's template cloning approach to testing is fast
3 hours ago
- pgtestdb is a Go/Postgres testing package that leverages Postgres template databases for fast test database cloning.
- Template database cloning is faster than migrating a test database from scratch and lighter than Docker-based approaches.
- River's test suite uses a schema-based isolation method that is slower than test transactions but has advantages like lighter weight than databases.
- Performance comparison showed similar setup times (~100ms) for both pgtestdb clone and create+migrate schema methods.
- River's schema-based approach achieved 3.5x faster overall wall time due to test schema pooling and reuse, which avoids re-migration.
- Schema reuse can be applied to pgtestdb as well, potentially reducing test setup to 10-20ms for large test suites.
- The author recommends pgtestdb for end-to-end testing but will keep River's schema-based method due to its incidental verification of schema configuration.