pgtest

package
v3.47.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package pgtest gives each test its own PostgreSQL database.

Without GLABS_TEST_PG_URI the tests skip, unless GLABS_TEST_PG_REQUIRED is set, which turns the skip into a failure. CI sets both, so a database that fails to come up breaks the build instead of quietly skipping every test -- without that, "green" and "never ran" are indistinguishable.

The databases are created from a TEMPLATE rather than migrated one by one. Today that saves little; it is the shape that keeps the suite fast as the schema grows, and it is what plexams.go arrived at with 64 tables.

Deliberately no Testcontainers. The dev container mounts no Docker socket, so a container per test could not start there at all; pointing an environment variable at a database that already exists works in both places.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(t *testing.T) *db.PG

NewDB returns a *db.PG on a fresh, migrated database, dropped when the test ends.

func NewDBWithURI

func NewDBWithURI(t *testing.T) (*db.PG, string)

NewDBWithURI is NewDB plus the connection string it used, for a test that has to hand the URI to something instead of using the handle.

Types

This section is empty.

Jump to

Keyboard shortcuts

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