Documentation
¶
Overview ¶
Package dbtest provides a variety of helpers for testing database (transactions etc).
Index ¶
Constants ¶
View Source
const ( DBName = "test_db" DBUser = "test_user" DBPass = "test_password" DBPort = "5432" )
Variables ¶
This section is empty.
Functions ¶
func TestDatabaseContainerRequest ¶
func TestDatabaseContainerRequest() testcontainers.GenericContainerRequest
Types ¶
type TestDatabase ¶
type TestDatabase struct { DbInstance *pgxpool.Pool DBPort string DBHost string Container testcontainers.Container }
TestDatabase represents - connection pool, a pool of connections ready to use - db address (host:port) to the running db - handle to running test container
func SetupTestDatabase ¶
func SetupTestDatabase(ctx context.Context, testDatabaseContainerRequest testcontainers.GenericContainerRequest, absoluteMigrationsPath string) (*TestDatabase, error)
func (*TestDatabase) TearDown ¶
func (tdb *TestDatabase) TearDown()
TearDown tears down the running database container
func (*TestDatabase) Truncate ¶
func (tdb *TestDatabase) Truncate() error
Click to show internal directories.
Click to hide internal directories.