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

pgtest

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pgtest provides throwaway PostgreSQL databases for integration tests. Tests are skipped unless SF_TEST_PG_DSN points at a server where the user may create databases, for example:

SF_TEST_PG_DSN='postgres://user@127.0.0.1:5432/postgres?sslmode=disable'

Index

Constants

View Source
const EnvDSN = "SF_TEST_PG_DSN"

EnvDSN names the environment variable holding the admin DSN.

View Source
const EnvRequired = "SF_TEST_PG_REQUIRED"

EnvRequired, when set to any value, makes a missing EnvDSN fail the test instead of skipping it, so a CI job meant to run PostgreSQL tests cannot pass without running them.

Variables

This section is empty.

Functions

func DSN

func DSN(t testing.TB) string

DSN returns a DSN for a fresh scratch database that is dropped when the test ends. It skips the test when EnvDSN is unset.

func Open

func Open(t testing.TB) *sql.DB

Open returns a *sql.DB for a fresh scratch database, closed and dropped when the test ends. It skips the test when EnvDSN is unset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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