testhelpers

package
v1.105.0-renovate-lock... Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestConn

type TestConn struct {
	Conn *pgxpool.Pool
}

func (TestConn) Begin

func (c TestConn) Begin(ctx context.Context) (pgx.Tx, error)

func (TestConn) Exec

func (c TestConn) Exec(ctx context.Context, s string, i ...interface{}) (pgconn.CommandTag, error)

func (TestConn) Query

func (c TestConn) Query(ctx context.Context, s string, i ...interface{}) (pgx.Rows, error)

func (TestConn) QueryRow

func (c TestConn) QueryRow(ctx context.Context, s string, i ...interface{}) pgx.Row

func (TestConn) SeedData

func (c TestConn) SeedData(data ...string)

type TestDatabase

type TestDatabase struct {
	Address   string
	Container *postgres.PostgresContainer
}

TestDatabase is a test utility containing a fully-migrated Postgres instance. To use this, run InitDb within a TestMain function and use the DbInstance to interact with the database as needed (e.g. to insert data prior to testing). Ensure to run TearDown at the end of the tests to clean up.

func InitDb

func InitDb() *TestDatabase

func (*TestDatabase) GetConn

func (db *TestDatabase) GetConn() TestConn

func (*TestDatabase) Restore

func (db *TestDatabase) Restore()

Restore restores the DB to the snapshot backup and re-establishes the connection

func (*TestDatabase) TearDown

func (db *TestDatabase) TearDown()

Jump to

Keyboard shortcuts

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