pgtest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package pgtest gives a test its own migrated Postgres database.

Each call creates a database on the server PGTEST_DSN points at, runs the app's migrations into it, and drops it when the test ends. Tests fail rather than skip when the server is unreachable, because a skipped suite reads as a green run; -short is the one way to opt out.

Index

Constants

View Source
const DSNEnv = "PGTEST_DSN"

DSNEnv names the admin connection: any database on the server, as a role that may CREATE DATABASE.

Variables

This section is empty.

Functions

func Pool

func Pool(t *testing.T, migrate func(context.Context, *pgxpool.Pool) error) *pgxpool.Pool

Pool returns a pool on a fresh database with migrate applied to it. The app passes its own migrations.Apply, so whatever the binary does at `migrate` is what a test database gets.

Types

This section is empty.

Jump to

Keyboard shortcuts

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