Documentation ¶
Index ¶
- func ApplyMigrations(t *testing.T, cfg *config.PostgresConfig)
- func CloneDB(t *testing.T, tp *TestPostgresContainer, pool *pgxpool.Pool) *pgxpool.Pool
- func CreateTestSchema(ctx context.Context, t *testing.T) (schema string)
- func DropTestSchema(ctx context.Context, t *testing.T, schema string)
- func GetTestConnectionPool(ctx context.Context, t *testing.T, cfg *config.PostgresConfig) *pgxpool.Pool
- func NewTestConnectionPool(ctx context.Context, t *testing.T) *pgxpool.Pool
- type InstanceConfig
- type TestPostgresContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyMigrations ¶
func ApplyMigrations(t *testing.T, cfg *config.PostgresConfig)
ApplyMigrations applies the migrations to the test database.
func CreateTestSchema ¶
CreateTestSchema creates a new test schema in the database.
func DropTestSchema ¶
DropTestSchema drops the test schema from the database.
func GetTestConnectionPool ¶
func GetTestConnectionPool(ctx context.Context, t *testing.T, cfg *config.PostgresConfig) *pgxpool.Pool
GetTestConnectionPool creates a new connection pool to the test database.
func NewTestConnectionPool ¶
NewTestConnectionPool creates a new test schema, applies migrations and returns a connection pool to the test database. This function also automatically registers a cleanup function to drop the test schema after the test has run.
Types ¶
type InstanceConfig ¶
func (InstanceConfig) DBConnStr ¶
func (c InstanceConfig) DBConnStr() string
type TestPostgresContainer ¶
type TestPostgresContainer struct { Container testcontainers.Container Cfg InstanceConfig // contains filtered or unexported fields }
func NewTestPostgresContainer ¶
func NewTestPostgresContainer(ctx context.Context, cfg InstanceConfig) (*TestPostgresContainer, error)
func (*TestPostgresContainer) Migrate ¶
func (tp *TestPostgresContainer) Migrate(dir string) error
func (*TestPostgresContainer) Pool ¶
func (tp *TestPostgresContainer) Pool(ctx context.Context, t *testing.T, cfg *InstanceConfig) *pgxpool.Pool
Click to show internal directories.
Click to hide internal directories.