testutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package testutils provides a minimal set of helpers used by the outbox test suite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestDB

func NewTestDB(dbConnStr, testName string, maxPool, maxIdle int) (*sqlx.DB, func(), error)

NewTestDB creates an isolated test database by cloning the template database referenced in dbConnStr. The new database is named "{template}_{testName}". The returned cleanup func drops it.

Intended for integration tests; expects a running Postgres with the outbox migrations already applied to the template DB.

func NewTestLogger

func NewTestLogger(t *testing.T) zerolog.Logger

NewTestLogger returns a console-formatted zerolog logger at Debug level.

func NoGoroutineLeak

func NoGoroutineLeak(t *testing.T)

NoGoroutineLeak ensures the calling test does not leave goroutines running after it returns. Used via:

defer testutils.NoGoroutineLeak(t)

func SeedTables

func SeedTables(t *testing.T, db *sql.DB, sqlFS fs.FS, seedScriptFileName string)

SeedTables executes a SQL file from the provided FS against the DB. Pass an empty seedScriptFileName to skip seeding.

func SetupMockDB

func SetupMockDB(t *testing.T) (*sqlx.DB, sqlmock.Sqlmock, func())

SetupMockDB returns a sqlx-wrapped sqlmock and a cleanup func.

Types

This section is empty.

Jump to

Keyboard shortcuts

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