Documentation
¶
Overview ¶
Package pgtest runs Postgres-backed tests against one shared testcontainers Postgres per test binary.
Wire it up in TestMain and request a database per test:
func TestMain(m *testing.M) { os.Exit(pgtest.Run(m)) }
func TestSomething(t *testing.T) {
pool := pgtest.New(t)
...
}
The documented docs/postgres/schema.sql is loaded once into a template database; every New call clones it with CREATE DATABASE … TEMPLATE. Postgres tests run by default, are skipped with -short, and fail when Docker is unavailable.
Index ¶
Constants ¶
View Source
const DefaultImage = "postgres:18"
DefaultImage is the Postgres image used when ImageEnv is unset.
View Source
const ImageEnv = "GOUTILS_TEST_PG_IMAGE"
ImageEnv names the environment variable that overrides the Postgres image.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.