dbtest

package
v0.0.0-...-6e596f9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

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

Jump to

Keyboard shortcuts

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