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

testdb

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testdb gives tests a fresh, empty Postgres database.

If AUTH_TEST_DATABASE_URL is set (a connection URL for a user allowed to create databases), it's used directly. Otherwise a Postgres container is started with testcontainers, which needs Docker.

Every call to New creates a separate database, dropped when the test ends, so tests can run in parallel without seeing each other's data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t testing.TB) *pgxpool.Pool

New returns a pool connected to a new, empty database.

func NewMigrated

func NewMigrated(t testing.TB) *pgxpool.Pool

NewMigrated returns a pool connected to a new database with the module's migrations applied.

Types

This section is empty.

Jump to

Keyboard shortcuts

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