testutil

package
v0.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestSchema

func CleanupTestSchema(ctx context.Context, execFunc func(context.Context, string) error) error

CleanupTestSchema removes test tables

func GetRealDatabaseConfig

func GetRealDatabaseConfig() *config.DBConfig

GetRealDatabaseConfig attempts to get database config from environment variables This is a helper that tests can use directly without creating a TestDatabase

func SetupTestSchema

func SetupTestSchema(ctx context.Context, execFunc func(context.Context, string) error) error

SetupTestSchema creates test tables in the given database connection This avoids import cycles by having tests call this with their connection

Types

type TestDatabase

type TestDatabase struct {
	Config *config.DBConfig
}

TestDatabase represents a test database instance

func NewTestDatabase

func NewTestDatabase(ctx context.Context, t *testing.T) (*TestDatabase, error)

NewTestDatabase creates a new PostgreSQL test database Uses environment variables or starts a Docker container

func (*TestDatabase) CleanupAfterTest

func (td *TestDatabase) CleanupAfterTest(ctx context.Context, t *testing.T)

CleanupAfterTest provides a cleanup function for use with t.Cleanup()

func (*TestDatabase) GetConfig

func (td *TestDatabase) GetConfig() *config.DBConfig

GetConfig returns the database configuration

Jump to

Keyboard shortcuts

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