pgtest

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pgtest shares one Postgres container across a test run, one database per package, with the admin, owner and app roles of 2de90d2:tests/conftest.py.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertUnprivileged

func AssertUnprivileged(t testing.TB, dsn string)

AssertUnprivileged fails t if dsn logs in as a role exempt from row-level security.

func ConceptRepository added in v0.7.0

func ConceptRepository(t testing.TB, dsn string) *repositories.ConceptRepository

ConceptRepository opens a store on dsn's okf schema, closed when t ends.

func Exec

func Exec(t testing.TB, dsn string, statements ...string)

Exec runs each statement on its own, autocommitted, as dsn's role.

func Main

func Main(m *testing.M, setup func(*DB) error)

Main runs the tests on the package's own database after setup, which migrates without an import cycle.

Types

type DB

type DB struct{ AdminDSN, OwnerDSN, AppDSN string }

func (*DB) LockOut

func (db *DB) LockOut(t testing.TB) (restore func())

LockOut makes db's database look down to the app role, until the returned func or t's end.

func (*DB) TerminateApp

func (db *DB) TerminateApp(t testing.TB)

TerminateApp ends every app-role backend on db's database, as a restart or failover would.

Jump to

Keyboard shortcuts

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