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

testdb

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package testdb gives each test a Postgres database of its own, created, migrated and dropped around it, so no test touches data it did not make.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStale

func IsStale(name, prefix string, serverEpoch int64) bool

IsStale reports a database made by Name more than staleAfter ago.

func Name

func Name(prefix string, serverEpoch int64) string

Name builds a test database name stamped with the server's clock, so IsStale on another machine judges its age by the same clock.

func Postgres

func Postgres(t testing.TB) *pgxpool.Pool

Postgres returns a pool on a fresh, migrated database. DATABASE_URL (URL or key=value form) names the server; the default is the local test one.

func Unavailable

func Unavailable(t testing.TB, format string, args ...any)

Unavailable skips the test, or fails it when REQUIRE_DB is set (CI).

Types

This section is empty.

Jump to

Keyboard shortcuts

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