testutils

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 15 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

Index

Constants

View Source
const (
	CheckViolationErrorCode         string = "check_violation"
	ExclusionViolationErrorCode     string = "exclusion_violation"
	FKViolationErrorCode            string = "foreign_key_violation"
	NotNullViolationErrorCode       string = "not_null_violation"
	UndefinedColumnErrorCode        string = "undefined_column"
	UndefinedTableErrorCode         string = "undefined_table"
	UniqueViolationErrorCode        string = "unique_violation"
	NumericValueOutOfRangeErrorCode string = "numeric_value_out_of_range"
)

Variables

This section is empty.

Functions

func SharedTestMain

func SharedTestMain(m *testing.M, postRunHooks ...func() error)

SharedTestMain starts a postgres container to be used by all tests in a package. Each test then connects to the container and creates a new database. Optional functions that will run after all tests can be added and should return a nil error to indicate they ran successfully. If they return an error all subsequent functions will be skipped.

func TestSchema

func TestSchema() string

TestSchema returns the schema in which migration tests apply migrations. By default, migrations will be applied to the "public" schema.

func WithConnectionToContainer

func WithConnectionToContainer(t *testing.T, fn func(*sql.DB, string))

func WithMigratorAndConnectionToContainer

func WithMigratorAndConnectionToContainer(t *testing.T, fn func(mig *roll.Roll, db *sql.DB))

func WithMigratorAndStateAndConnectionToContainerWithOptions

func WithMigratorAndStateAndConnectionToContainerWithOptions(t *testing.T, opts []roll.Option, fn func(*roll.Roll, *state.State, *sql.DB))

func WithMigratorInSchemaAndConnectionToContainer

func WithMigratorInSchemaAndConnectionToContainer(t *testing.T, schema string, fn func(mig *roll.Roll, db *sql.DB))

func WithMigratorInSchemaAndConnectionToContainerWithOptions

func WithMigratorInSchemaAndConnectionToContainerWithOptions(t testing.TB, schema string, opts []roll.Option, fn func(mig *roll.Roll, db *sql.DB))

func WithStateAndConnectionToContainer

func WithStateAndConnectionToContainer(t *testing.T, fn func(*state.State, *sql.DB))

func WithStateAtVersionAndConnectionToContainer added in v0.14.0

func WithStateAtVersionAndConnectionToContainer(t *testing.T, version string, fn func(*state.State, string, *sql.DB))

func WithStateInSchemaAndConnectionToContainer

func WithStateInSchemaAndConnectionToContainer(t *testing.T, schema string, fn func(*state.State, *sql.DB))

func WithUninitializedState

func WithUninitializedState(t *testing.T, fn func(*state.State))

func WithUninitializedStateAndConnectionInfo added in v0.13.0

func WithUninitializedStateAndConnectionInfo(t *testing.T, fn func(*state.State, string, *sql.DB))

Types

This section is empty.

Jump to

Keyboard shortcuts

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