pgtest

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pgtest isolates PostgreSQL test packages in disposable schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset(t testing.TB, db *sqlx.DB)

Reset empties every user table in the current schema — except the migration bookkeeping table — and restarts identity sequences, so fixture primary keys are deterministic across runs. Call it right after opening the database and before AutoMigrate.

All tables are truncated together so intra-schema foreign keys need no deletion order. Do not use CASCADE: a foreign key from another schema must fail the reset, not silently clear another fixture. ONLY likewise prevents PostgreSQL from implicitly including descendants in another schema. Table identifiers are quoted by PostgreSQL itself.

func Run added in v0.29.2

func Run(m *testing.M) (code int)

Run is the TestMain entry point for packages using Reset. Put search_path in the DSN so every connection, including subprocess clients, gets it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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