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

testdb

package
v0.0.0-...-af5a29e Latest Latest
Warning

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

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

Documentation

Overview

Package testdb gives a test its own empty Postgres database with pcom's migrations applied. The database is dropped when the test ends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t testing.TB) *postgres.TestDB

New returns a fresh, fully migrated database. Use TestDB.DB (*sqlx.DB) as the executor and TestDB.URL to hand the database to a subprocess.

gogo connects with lib/pq; New reconnects through pgx, the driver the server uses, so tests run on the production driver. gogo's cleanup closes whatever TestDB.DB holds before it drops the database, so the pgx connection is closed first.

Types

This section is empty.

Jump to

Keyboard shortcuts

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