testhelpers

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

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequireDocker

func RequireDocker(t *testing.T)

RequireDocker skips the test if Docker is not available

func StartNATSServer

func StartNATSServer(t *testing.T) *server.Server

StartNATSServer starts an embedded NATS server for testing Returns a NATS server instance that should be shut down with Shutdown()

Types

type PostgresContainer

type PostgresContainer struct {
	Container       *postgres.PostgresContainer
	ConnectionStr   string
	DB              *db.DB
	UsingExistingDB bool
	// contains filtered or unexported fields
}

PostgresContainer holds the testcontainer instance and connection details

func SetupTestDatabase

func SetupTestDatabase(t *testing.T) *PostgresContainer

SetupTestDatabase creates a PostgreSQL testcontainer with TimescaleDB and pgvector

func (*PostgresContainer) AddCleanup

func (tc *PostgresContainer) AddCleanup(fn func())

AddCleanup registers a cleanup function to be called during teardown

func (*PostgresContainer) ApplyMigrations

func (tc *PostgresContainer) ApplyMigrations(migrationsPath string) error

ApplyMigrations runs SQL migrations from the migrations directory

func (*PostgresContainer) ApplyMigrationsLegacy

func (tc *PostgresContainer) ApplyMigrationsLegacy() error

ApplyMigrationsLegacy provides a minimal schema if migration file is not available

func (*PostgresContainer) Cleanup

func (tc *PostgresContainer) Cleanup()

Cleanup terminates the container and runs cleanup functions

func (*PostgresContainer) ExecuteSQL

func (tc *PostgresContainer) ExecuteSQL(sql string) error

ExecuteSQL executes arbitrary SQL (useful for test setup)

func (*PostgresContainer) TruncateAllTables

func (tc *PostgresContainer) TruncateAllTables() error

TruncateAllTables clears all data from tables (useful for test isolation)

Jump to

Keyboard shortcuts

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