pgtest

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package pgtest provides Postgres for integration tests.

Index

Constants

View Source
const DefaultImage = "postgres:17"

Variables

This section is empty.

Functions

func LeakOptions

func LeakOptions() []goleak.Option

func Main

func Main(m *testing.M, db **Database) int

Main is a TestMain body that starts the database and runs the tests.

Types

type Database

type Database struct {
	URL string
	// contains filtered or unexported fields
}

Database is a Postgres server shared by the tests of one package.

func Start

func Start(ctx context.Context) (*Database, error)

Start returns the server named by FOREMAN_TEST_DATABASE_URL or starts a container.

func (*Database) Close

func (d *Database) Close()

func (*Database) Pool

func (d *Database) Pool(tb testing.TB) *pgxpool.Pool

func (*Database) Schema

func (d *Database) Schema(tb testing.TB, pool *pgxpool.Pool) string

Schema creates a fresh migrated schema and drops it when the test ends.

Jump to

Keyboard shortcuts

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