testutils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecMigration added in v1.1.0

func ExecMigration(db *sql.DB)

func InsertSeed added in v1.1.0

func InsertSeed(db *sql.DB)

InsertSeed inserts test seed data

func ResetMigration added in v1.1.0

func ResetMigration(db *sql.DB)

ResetMigration resets the database migration

func SetupPostgres added in v1.1.0

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

SetupPostgres starts a postgres container

Types

type PostgresTestSuite added in v1.1.0

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

func SetupPostgresTestSuite added in v1.1.0

func SetupPostgresTestSuite(ctx context.Context) *PostgresTestSuite

func (*PostgresTestSuite) CloseConnTemporary added in v1.1.0

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

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

func (*PostgresTestSuite) ExecQuery added in v1.1.0

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

func (*PostgresTestSuite) InsertSeed added in v1.1.0

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 added in v1.1.0

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

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

func (*PostgresTestSuite) SwitchQuerier added in v1.1.0

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

func (*PostgresTestSuite) TakeSnapshot added in v1.1.0

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

func (*PostgresTestSuite) Terminate added in v1.1.0

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