testutils

package
v1.0.1-pre Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecMigration

func ExecMigration(db *sql.DB)

func InsertSeed

func InsertSeed(db *sql.DB)

InsertSeed inserts test seed data

func ResetMigration

func ResetMigration(db *sql.DB)

ResetMigration resets the database migration

func SetupPostgres

func SetupPostgres(ctx context.Context) *postgres.PostgresContainer

SetupPostgres starts a postgres container

Types

type PostgresTestSuite

type PostgresTestSuite struct {
	Container *postgres.PostgresContainer
	URL       string
	Store     *store.Store
	// contains filtered or unexported fields
}

func SetupPostgresTestSuite

func SetupPostgresTestSuite(ctx context.Context) *PostgresTestSuite

func (*PostgresTestSuite) CloseConnTemporary

func (s *PostgresTestSuite) CloseConnTemporary(t testing.TB)

CloseConn closes the connection. After the test, the connection will be re-established.

func (*PostgresTestSuite) ExecQuery

func (s *PostgresTestSuite) ExecQuery(t testing.TB, query string, args ...any) (pgx.Rows, error)

func (*PostgresTestSuite) InsertSeed

func (s *PostgresTestSuite) InsertSeed(t testing.TB, dir string)

InsertSeed inserts test seed data based on the seed path. Seed path is relative to the root directory.

func (*PostgresTestSuite) ResetDB

func (s *PostgresTestSuite) ResetDB(t testing.TB)

ResetDB resets the database to the state of the snapshot without data

func (*PostgresTestSuite) SwitchQuerier

func (s *PostgresTestSuite) SwitchQuerier(t testing.TB, querier sqlc.Querier)

func (*PostgresTestSuite) TakeSnapshot

func (s *PostgresTestSuite) TakeSnapshot(t testing.TB, snapshotName string)

func (*PostgresTestSuite) Terminate

func (s *PostgresTestSuite) Terminate(ctx context.Context)

Jump to

Keyboard shortcuts

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