testdb

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Overview

Package testdb gives integration tests a Postgres database of their own.

Each test gets a fresh schema, so tests run in parallel and leave nothing behind, unless the test binary is killed. The database comes from HOPPER_TEST_DATABASE_URL; without it, integration tests are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Database added in v0.8.0

func Database(t testing.TB, options string) string

Database creates a database for this test, with the CREATE DATABASE options given, and returns its URL. It is dropped when the test ends.

func Driver added in v0.3.0

func Driver(pool *pgxpool.Pool) *hopperpgx.Driver

Driver binds the driver to the isolated schema created by EmptyPool.

func EmptyPool

func EmptyPool(t testing.TB, maxConns int32) *pgxpool.Pool

EmptyPool is like Pool but leaves the schema empty, for migration tests. maxConns of 0 uses the pgxpool default.

func Pool

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

Pool returns a pool whose search_path is a schema created for this test, with hopper's schema installed. The schema is dropped when the test ends.

func PoolIn added in v0.8.0

func PoolIn(t testing.TB, dbURL string) *pgxpool.Pool

PoolIn is like Pool, in the database at dbURL.

func URL

func URL(t testing.TB) string

URL returns HOPPER_TEST_DATABASE_URL or skips the test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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