Help us shape the future of Go! Take the 2026 Go Developer Survey

dbtest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package dbtest provides a parallel-safe test database harness. Each caller gets a freshly cloned database from a template that has all migrations applied.

Usage:

func TestSomething(t *testing.T) {
    pool := dbtest.NewTestDB(t)
    // pool is a *pgxpool.Pool against a freshly cloned DB.
}

The harness reads SHITHUB_TEST_DATABASE_URL for the bootstrap connection (used to CREATE/DROP databases). Tests are skipped if the env var is not set, so unit tests stay green on machines without Postgres.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB(t *testing.T) *pgxpool.Pool

NewTestDB returns a *pgxpool.Pool against a freshly created database cloned from the per-test-suite template. The database is dropped on t.Cleanup. Calls t.Skip if SHITHUB_TEST_DATABASE_URL is unset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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