pgtest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pgtest creates isolated Postgres schemas for tests.

The Postgres behind these tests is the long-lived one from docker-compose, so anything created here and then abandoned stays there until someone drops it by hand. Each resource is handed to t.Cleanup as soon as it exists, which releases it in reverse order and runs even for the t.Fatalf calls below.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresSchema

func NewPostgresSchema(t *testing.T, sqlFiles []string, opts ...Option) *pgx.Conn

NewPostgresSchema opens a connection with search_path set to a randomly named, new schema and loads all sqlFiles.

func NewPostgresSchemaString

func NewPostgresSchemaString(t *testing.T, sql string, opts ...Option) *pgx.Conn

NewPostgresSchemaString opens a connection with search_path set to a randomly named, new schema and loads the sql string.

Types

type Option

type Option func(config *pgx.ConnConfig)

Jump to

Keyboard shortcuts

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