testpg

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package testpg provides isolated PostgreSQL schemas for tests and the system-test server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseDSN

func BaseDSN() (string, error)

BaseDSN returns SYNAPS3_POSTGRES_TEST_DSN when set; otherwise it starts one PostgreSQL container per process.

func Close

func Close() error

Close terminates only the container created by this process. Call after m.Run.

func CreateSchema

func CreateSchema(ctx context.Context, dsn string) (string, func(context.Context) error, error)

CreateSchema creates an empty private schema in the database named by dsn and returns a DSN whose connections use it. Close every connection to the returned DSN before calling drop.

func DSN

func DSN(t *testing.T) string

DSN returns the external test DSN or starts one PostgreSQL container per process.

func Main

func Main(m *testing.M)

Main runs a package's tests and then terminates the container this process started. Call it from TestMain.

func SchemaDSN

func SchemaDSN(t *testing.T) string

SchemaDSN creates an empty private schema and sets search_path on every connection. Register connection cleanup after calling it so connections close before the schema.

Types

This section is empty.

Jump to

Keyboard shortcuts

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