pgtest

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pgtest gives a test a pool on a private migrated schema.

Index

Constants

View Source
const BinEnv = "MOTTE_TEST_PG_BIN"

BinEnv names a directory that holds initdb and postgres. Without it, Pool looks for both on PATH.

View Source
const DSNEnv = "MOTTE_TEST_DATABASE_URL"

DSNEnv is the environment variable that Pool reads when it gets no DSN.

View Source
const RequireEnv = "MOTTE_TEST_REQUIRE_PG"

RequireEnv set to 1 makes Pool fail, not skip, when no database is available.

Variables

This section is empty.

Functions

func Pool

func Pool(t testing.TB, dsn string) *pgxpool.Pool

Pool creates a fresh schema in the database at dsn, applies the migrations and returns a pool on it. An empty dsn is read from DSNEnv. When that is empty too, Pool starts one throwaway cluster for the package from the binaries of BinEnv or PATH. Without binaries it skips the test, or fails it when RequireEnv is 1. Cleanup drops the schema.

func RequiredPool added in v0.19.0

func RequiredPool(t testing.TB, dsn string) *pgxpool.Pool

RequiredPool is Pool, but it fails the test, not skips it, when no database is available.

Types

This section is empty.

Jump to

Keyboard shortcuts

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