database

package
v0.0.0-...-0888c82 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

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 CloneDB

func CloneDB(t *testing.T, tp *TestPostgresContainer, pool *pgxpool.Pool) *pgxpool.Pool

func CreateTestSchema

func CreateTestSchema(ctx context.Context, t *testing.T) (schema string)

CreateTestSchema creates a new test schema in the database.

func DropTestSchema

func DropTestSchema(ctx context.Context, t *testing.T, schema string)

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

func NewTestConnectionPool(ctx context.Context, t *testing.T) *pgxpool.Pool

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

type InstanceConfig struct {
	User     string
	Password string
	DBName   string
	Host     string
	Port     int
}

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

Jump to

Keyboard shortcuts

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