testdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package testdb gives each test its own PostgreSQL database, built from the DDL the test passes and dropped when the test ends.

TEST_DATABASE_URL points at the server (any database on it). Tests skip when it is unreachable and TEST_DATABASE_REQUIRED is unset, so a plain `go test ./...` without Postgres still runs the rest; CI sets it.

Index

Constants

View Source
const DefaultURL = "postgres://searchnzb:dev@localhost:55432/postgres"

DefaultURL is the development server the tests use without TEST_DATABASE_URL.

Variables

This section is empty.

Functions

func New

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

New returns a pool on a fresh database where every script of ddl has run.

func WithDatabase

func WithDatabase(url, name string) string

WithDatabase is url with its database replaced by name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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