FREEDOM251

Freedom251 › Database Testing Tools

pgtestdb

Free plan Self-hosted

Visit pgtestdb Alternatives Pricing

pgtestdb's own site

What pgtestdb is

pgtestdb is a free, open-source Go library for database-backed tests that use PostgreSQL. It prepares a migrated template database, then clones it so each test runs against its own isolated database. The project describes creating a test database from the template as taking on the order of 10 milliseconds, and says separate databases allow tests to run in parallel safely.

The library uses Go’s database/sql interface, with support for pgx, lib/pq, and other compatible drivers. Its built-in migration adapters cover pgmigrate, golang-migrate, goose, dbmate, Atlas, sql-migrate, Bun, and Tern; custom migrators can also be used. You provide a running Postgres server, which may be Docker-based, installed locally, or remote. The configured server user must be able to create databases and roles, and the project recommends using a dedicated testing server. Databases created for passing tests are removed automatically. When a test fails, its database is kept and a connection string is logged for inspection. pgtestdb is MIT licensed and maintained under the peterldowns GitHub account.

Who it suits

pgtestdb suits Go developers who need isolated PostgreSQL databases for schema migration tests or other database-backed tests. It is particularly relevant to teams running tests in parallel and using a supported migration tool or custom migrator.

What it does well

  • Creates a separate migrated database for each test.
  • Clones a template database, with creation described as taking about 10 milliseconds.
  • Supports parallel tests with separate databases.
  • Includes adapters for eight migration tools and supports custom migrators.
  • Keeps failed-test databases and logs a connection string for inspection.
  • Free, open source, and MIT licensed.

What to know first

  • Requires users to provide a running Postgres server.
  • The server user needs permission to create databases and roles.
  • The default test role cannot create extensions by default.
  • Highly parallel suites can exceed the server’s connection limit.

Limits

The default test role has NOSUPERUSER, NOCREATEDB, and NOCREATEROLE capabilities, so it cannot create extensions by default. Highly parallel test suites can also exceed the Postgres server’s connection limit; the project suggests adjusting test parallelism or server capacity.

Plans

PlanBilled and limitsPrice
pgtestdbOpen source Go library · requires a Postgres serverFree

As github.com lists them, read 4 Oct 2026. The maker's own page has the final word.

Getting started

  1. Provide a running Postgres server, using Docker, a native installation, or a remote server.
  2. Configure a server user that can create databases and roles; use a dedicated testing server.
  3. Use Go’s database/sql interface with pgx, lib/pq, or another compatible driver.
  4. Connect a built-in migration adapter or provide a custom migrator.
  5. Run tests so pgtestdb can build a migrated template and clone a database for each test.

Verdict

Choose pgtestdb if your Go tests need isolated PostgreSQL databases, especially when you want parallel execution and integration with common migration tools. It requires a running Postgres server with database and role creation permissions, so teams without that infrastructure should look elsewhere.

Questions

How much does pgtestdb cost?

The listed plan is free. The project is open source.

Which database does pgtestdb support?

It supports PostgreSQL and requires you to provide a running Postgres server.

Which Go database drivers can I use?

It uses Go’s database/sql interface and supports pgx, lib/pq, or another compatible driver.

Which migration tools are supported?

Built-in adapters are listed for pgmigrate, golang-migrate, goose, dbmate, Atlas, sql-migrate, Bun, and Tern. Custom migrators are also supported.

Can tests run in parallel?

Yes. Each test gets its own database, and the project describes pgtestdb as concurrency-safe for parallel tests.

Who maintains pgtestdb, and what is its license?

It is maintained under the peterldowns GitHub account and is MIT licensed.

Facts from pgtestdb's own pages

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. · github.com, 4 Oct 2026
Concurrency
Each test gets its own database, and the README says pgtestdb is concurrency-safe for parallel tests. · github.com, 4 Oct 2026
Database drivers
The library uses Go's database/sql interface and supports pgx, lib/pq, or another database/sql driver. · github.com, 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. · github.com, 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. · github.com, 4 Oct 2026
License
The repository identifies the project as MIT licensed. · github.com, 4 Oct 2026
Maker
The repository is maintained under the GitHub account peterldowns; the opened project page does not state a maker name, headquarters, or founding date. · github.com, 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. · github.com, 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. · github.com, 4 Oct 2026
Postgres requirement
Users must provide a running Postgres server; the README describes Docker, native installations, and remote servers as options. · github.com, 4 Oct 2026
Purpose
pgtestdb is a Go library for database-backed tests that provisions an isolated, migrated Postgres database for each test. · github.com, 4 Oct 2026
Speed
The README says creating a test database from a template takes on the order of 10 milliseconds. · github.com, 4 Oct 2026
Template databases
It runs migrations once to build a template database and clones that template for individual tests. · github.com, 4 Oct 2026

Where pgtestdb stands on Freedom251

Look at these too