testutils

package
v0.0.1-rc.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package testutils provides testing utilities including database containers and test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTestDataFilePath

func GetTestDataFilePath(file string) string

GetTestDataFilePath returns the absolute path to a test data file It looks for a "testdata" directory relative to the calling test file

func SetupTestEnv

func SetupTestEnv(t testing.TB)

SetupTestEnv loads environment variables from .env.test file in priority order godotenv.Load() does NOT overwrite existing environment variables, so CI/CD variables (e.g., GitHub Secrets) take precedence automatically

Priority order: 1. Environment variables (CI/CD secrets) - never overwritten 2. .env.test - for test-specific variables

func SetupTestEnvWithRequiredVarsOrSkipTest

func SetupTestEnvWithRequiredVarsOrSkipTest(t testing.TB, requiredVars ...string)

SetupTestEnvWithRequiredVarsOrSkipTest loads environment variables and verifies required ones are set Skips the test if any required variable is missing

func SetupTestManager

func SetupTestManager(t testing.TB, opts ...TestManagerOptions) (*database.Manager, func())

SetupTestManager creates a Manager with testcontainer and migrations

Types

type PostgresContainer

type PostgresContainer struct {
	*postgres.PostgresContainer
	ConnectionString string
}

PostgresContainer embeds the testcontainers PostgresContainer and adds the ConnectionString field.

func SetupPostGISContainer

func SetupPostGISContainer(ctx context.Context) (*PostgresContainer, error)

SetupPostGISContainer creates a PostGIS container with testcontainers

type TestManagerOptions

type TestManagerOptions struct {
	// MigrationsPath path to migration files (default: "/migrations" at project root)
	MigrationsPath string
	// SkipMigrations disables automatic migrations
	SkipMigrations bool
	// MigrationsSchema schema for migrations table (default: "public")
	MigrationsSchema string
	// MigrationsTable table name for migrations (default: "schema_migrations")
	MigrationsTable string
}

TestManagerOptions sets behavior of SetupTestManager

Jump to

Keyboard shortcuts

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