testutils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustExec

func MustExec(t *testing.T, ds sqlutil.DataSource, stmt string, args ...interface{})

func NewIndependentSqlxDB

func NewIndependentSqlxDB(t testing.TB) *sqlx.DB

NewIndependentSqlxDB return a new independent test database, which does not use txdb and therefore supports txs etc. Use this with caution, as it is much more costly than NewSqlxDB.

func NewIndependentSqlxDBs added in v1.1.3

func NewIndependentSqlxDBs(t testing.TB, n int) []*sqlx.DB

NewIndependentSqlxDBs returns n handles to a single fresh test database, which does not use txdb and therefore supports real transactions and lock contention between connections. Use this with caution, as it is much more costly than NewSqlxDB.

func NewIndependentSqlxSessions added in v1.1.3

func NewIndependentSqlxSessions(t testing.TB, n int) []*sqlx.DB

NewIndependentSqlxSessions returns n handles to a single fresh test database, each pinned to its own connection (pool size 1). Unlike the handles from NewIndependentSqlxDBs, session state such as SET or an open transaction does not leak between them, which makes it suitable for tests that hold locks on one session while another session contends for them.

lock_timeout is set so that a regression that makes a query wait on a lock fails the test instead of hanging it.

func NewSqlxDB

func NewSqlxDB(t testing.TB) *sqlx.DB

func SkipShortDB

func SkipShortDB(tb testing.TB)

SkipShortDB skips tb during -short runs, and notes the DB dependency.

Types

This section is empty.

Jump to

Keyboard shortcuts

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