testdb

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package testdb provides fully isolated, migrated Postgres databases for integration tests. Each test gets its own database cloned from a migrated template (via pgtestdb), so creation is cheap and tests can run in parallel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Pool *pgxpool.Pool
	URL  string
}

Database owns one migrated per-test database and a pool connected to it.

func New

func New(t testing.TB) *Database

New returns a migrated database private to the calling test, cloned from a template that is migrated once per package run. Skips the test when TEST_DATABASE_URL is unset. Cleanup is automatic; a failed test's database is kept for inspection (pgtestdb logs its connection string).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL