pgtest

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 4 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 resets shared PostgreSQL fixtures between tests. Packages must run serially because they share the database selected by PG_TEST_DSN:

PG_TEST_DSN=... go test ./... -count=1 -tags=integration -p 1

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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