pgtest

package module
v0.0.0-...-8c2b701 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package pgtest hands each test binary its own freshly created postgres database and connection URL, plus FreshPool for a reset, migrated, connected pool on top. The server is the shared container from PGTEST_URL when set, else a per-binary testcontainer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreshPool

func FreshPool(t *testing.T, fsys fs.FS, dir string) *pgxpool.Pool

FreshPool returns a connected pool against this binary's database, reset to a clean schema and migrated from fsys/dir. Each service supplies its own embedded migrations.

func URL

func URL(t *testing.T) string

URL returns this binary's database URL: drop-and-recreated on first call, memoized after. Call it directly from the package under test - the database name derives from the caller's directory, keeping binaries under `go test -p 2` on separate databases. Prefer FreshPool unless you need a reset database without a forced migrate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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