pgtestdb
pgtestdb is a free, open-source Go library for database-backed tests that need isolated PostgreSQL databases.
What pgtestdb is
pgtestdb is a free, open-source Go library for database-backed tests that need isolated PostgreSQL databases. It runs migrations to build a template database, then clones that template for individual tests. The README puts creation of a database from the template at around 10 milliseconds and describes the library as safe for parallel tests. It uses Go’s database/sql interface and supports pgx, lib/pq, and other compatible drivers. Built-in migration adapters include pgmigrate, golang-migrate, goose, dbmate, Atlas, sql-migrate, Bun, and Tern, with custom migrators also supported. You must provide a running Postgres server, whether Docker-based, installed locally, or remote. The configured user needs permission to create databases and roles, and the project recommends a dedicated testing server rather than production. Databases from passing tests are deleted automatically; when a test fails, its database remains available and a connection string is logged for inspection. The project is MIT licensed.
Good
- Creates a separate database for each test.
- Supports parallel tests.
- Includes adapters for multiple migration tools.
- Failed-test databases remain available for inspection.
- Free and MIT licensed.
Watch out
- Requires a running Postgres server.
- The server user must create databases and roles.
- Default test role cannot create extensions.
Who it suits
It suits Go developers who want isolated PostgreSQL databases for database-backed tests, including parallel tests. Users need access to a running Postgres server and a server account able to create databases and roles.
Verdict
pgtestdb provides isolated PostgreSQL test databases with migration integrations and a failed-test inspection path. Account permissions and server connection limits are worth considering before using it in a test suite.
Plans and prices
From pgtestdb's own pricing page, checked 4 Oct 2026.
| Plan | Price | What it gives you |
|---|---|---|
| pgtestdb | Free | Open source Go library · requires a Postgres server |
The facts
Each one read from pgtestdb's own pages, with the date it was checked.
What it does
- Cleanup and debugging
- Databases from passing tests are deleted automatically, while a failed test leaves its database available and logs a connection string for inspection.checked 4 Oct 2026
- Concurrency
- Each test gets its own database, and the README says pgtestdb is concurrency-safe for parallel tests.checked 4 Oct 2026
- Database drivers
- The library uses Go's database/sql interface and supports pgx, lib/pq, or another database/sql driver.checked 4 Oct 2026
- Database limits
- The README notes that highly parallel test suites can exceed a Postgres server's connection limit and suggests tuning test parallelism or server capacity.checked 4 Oct 2026
- Default test role
- The default role used for test databases has NOSUPERUSER, NOCREATEDB, and NOCREATEROLE capabilities, so it cannot create extensions by default.checked 4 Oct 2026
- License
- The repository identifies the project as MIT licensed.checked 4 Oct 2026
- Migration integrations
- Built-in adapters are listed for pgmigrate, golang-migrate, goose, dbmate, Atlas, sql-migrate, Bun, and Tern; custom migrators are also supported.checked 4 Oct 2026
- Permissions
- The configured server user needs capabilities to create databases and roles, and the README recommends using a dedicated testing server rather than production.checked 4 Oct 2026
- Postgres requirement
- Users must provide a running Postgres server; the README describes Docker, native installations, and remote servers as options.checked 4 Oct 2026
- Purpose
- pgtestdb is a Go library for database-backed tests that provisions an isolated, migrated Postgres database for each test.checked 4 Oct 2026
- Speed
- The README says creating a test database from a template takes on the order of 10 milliseconds.checked 4 Oct 2026
- Template databases
- It runs migrations once to build a template database and clones that template for individual tests.checked 4 Oct 2026
The company
- Maker
- The repository is maintained under the GitHub account peterldowns; the opened project page does not state a maker name, headquarters, or founding date.checked 4 Oct 2026
Alternatives to pgtestdb
- 1

Atlas
Free planOpen sourceWebAPILinuxmacOS8.3From $39 a month - 2

DataKitchen TestGen
Free planOpen sourceWebAPILinuxmacOS8.1From $100 a month - 3

Soda
Free planWebAPILinuxSelf-hosted7.5From $750 a month - 4
Avidemux
Free planOpen sourceWebLinuxmacOSWindows7.3Free plan - 5
pgroll
Free planOpen sourceLinuxmacOSSelf-hostedWindows7.3Free plan - 6

Bytebase Enterprise
Free planWebAPISelf-hosted6.8From $20 a month
