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

testutil

package
v0.0.0-...-95dcaac Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StopPostgresContainer

func StopPostgresContainer(
	ctxStop context.Context,
	pgContainer *PostgresContainer,
) error

StopPostgresContainer stops a PostgreSQL container.

Types

type PostgresContainer

type PostgresContainer struct {
	*tcpostgres.PostgresContainer
	// contains filtered or unexported fields
}

PostgresContainer represents a PostgreSQL container for testing.

func StartPostgresContainer

func StartPostgresContainer(ctx context.Context) (*PostgresContainer, error)

StartPostgresContainer starts a new PostgreSQL container using testcontainers.

func (*PostgresContainer) CreateDB

func (c *PostgresContainer) CreateDB(
	ctx context.Context,
	t *testing.T,
) (contract.DB, func(), error)

CreateDB creates a new isolated database cloned from the template. It returns the pgx connection, cleanup function, and any error.

func (*PostgresContainer) SetupTemplateDB

func (c *PostgresContainer) SetupTemplateDB(
	ctx context.Context,
	dbNameTemplate string,
	schemaDDL string,
) error

SetupTemplateDB creates a template database with the initial schema DDL.

Jump to

Keyboard shortcuts

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