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

pgtest

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pgtest gives tests a real PostgreSQL: one container per test binary, a fresh database per test. Tests skip when no container runtime answers. To use a server of your own instead, set DEVOPUS_TEST_DATABASE_URL to a connection URL with the right to create databases.

The package's TestMain must run the tests with Run so the container goes away after them: func TestMain(m *testing.M) { os.Exit(pgtest.Run(m)) }

Index

Constants

View Source
const Image = "postgres:17-alpine"

Image is the PostgreSQL the tests run against.

Variables

This section is empty.

Functions

func Pool

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

Pool is a connection pool to a fresh database, closed after the test.

func Run

func Run(m *testing.M) int

Run runs the tests and removes the container; it returns the exit code.

func URL

func URL(t testing.TB) string

URL creates an empty database for the test and returns its connection URL. The database is dropped after the test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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