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

postgres

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package postgres provides a generic testcontainers-based PostgreSQL database for integration tests.

It is deliberately schema-agnostic: it starts a real PostgreSQL container and exposes the DSN, but applies NO application schema (no ORM schema, no consumer tables). A caller that needs a schema provisions it over the DSN — e.g. River applies its own migration, and a consumer's schema fixture can wrap this to run its own migrations. Keeping this fixture generic is what lets the engine's client integration tests (River, etc.) run without any consumer schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestDatabase

type TestDatabase struct {
	// contains filtered or unexported fields
}

TestDatabase wraps a testcontainers PostgreSQL instance. It holds no application schema — callers migrate over GetDSN() as needed.

func NewTestDatabase

func NewTestDatabase(ctx context.Context) (*TestDatabase, error)

NewTestDatabase starts a PostgreSQL container and returns a TestDatabase whose DSN points at an empty database (no schema applied).

func (*TestDatabase) Close

func (td *TestDatabase) Close(ctx context.Context)

Close terminates the container.

func (*TestDatabase) GetDSN

func (td *TestDatabase) GetDSN() string

GetDSN returns the PostgreSQL connection string for direct SQL access.

func (*TestDatabase) OpenDB

func (td *TestDatabase) OpenDB() (*sql.DB, error)

OpenDB opens a *sql.DB over the pgx driver for the container's DSN. The caller owns the returned handle and must Close it.

Jump to

Keyboard shortcuts

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