pgtest

package
v0.0.0-...-85df02f Latest Latest
Warning

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

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

Documentation

Overview

Package pgtest runs integration tests against a real PostgreSQL in a throwaway container. Import it only from tests.

Index

Constants

View Source
const Image = "postgres:18.7-trixie@sha256:eb63372c1e05c755f55fa30cbd07aecc443676fc6c0fa90b9002d01537841e1a"

Image matches the PostgreSQL image in Docker Compose.

Variables

This section is empty.

Functions

func Main

func Main(m *testing.M) int

Main starts one container for a package's tests, runs them and removes it. Use it as: func TestMain(m *testing.M) { os.Exit(pgtest.Main(m)) }.

func NewDSN

func NewDSN(t *testing.T) string

NewDSN creates an empty database and returns its connection string; the database is dropped when the test ends.

func NewDatabase

func NewDatabase(t *testing.T, migrations ...postgres.Migration) *pgxpool.Pool

NewDatabase creates an empty database, applies the migrations and returns a pool to it. The database is dropped when the test ends.

Types

This section is empty.

Jump to

Keyboard shortcuts

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