dbtest

package
v0.0.0-...-dd88ed8 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDBTestContainer

func CreateDBTestContainer(ctx context.Context, name string, inMemory bool) (testcontainers.Container, *sql.DB, error)

CreateDBTestContainer spins up a Postgres database container

func DBForTest

func DBForTest(name string, opts ...DBForTestOption) (db *sql.DB, resolvedData *debefix.Data, closeFunc func() error, err error)

DBForTest spins up a postgres container, creates the test database on it, migrates it, and returns the db and a close function. The "name" parameter will become the test database name with a "_test" suffix as required by testfixtures.

func DBMigrationTest

func DBMigrationTest(name string) (err error)

DBMigrationTest tests the complete migration (up and down).

func MigrationsPath

func MigrationsPath() (string, error)

func NewDBPGMigrator

func NewDBPGMigrator(db *sql.DB) (*migrate.Migrate, error)

NewDBPGMigrator creates a migrator instance

Types

type DBForTestOption

type DBForTestOption func(*dbForTestOptions)

func WithDBForTestDebugOutput

func WithDBForTestDebugOutput(debugOutput bool) DBForTestOption

func WithDBForTestFixturesTags

func WithDBForTestFixturesTags(fixturesTags []string) DBForTestOption

func WithDBForTestInDisk

func WithDBForTestInDisk(inDisk bool) DBForTestOption

func WithDBForTestMergeData

func WithDBForTestMergeData(data []string) DBForTestOption

Jump to

Keyboard shortcuts

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