testutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package testutil provides generic, domain-agnostic test helpers for services built on go-foundation: in-memory SQLite databases, ready-made test configurations, and (behind the "integration" build tag) a PostgreSQL testcontainers harness.

Package testutil's PostgreSQL harness logic lives here, deliberately WITHOUT the "integration" build tag, so the branchy setup/reset/skip logic is unit testable with a fake executor and injected seams — no container or live database required. The heavy, testcontainers-backed wiring that drives this logic stays in postgres.go behind the "integration" tag.

Index

Constants

View Source
const TestDatabaseURLEnv = "FOUNDATION_TEST_DATABASE_URL"

TestDatabaseURLEnv is the env var that, when set, points the harness at an already-running PostgreSQL instance instead of booting a container.

Variables

This section is empty.

Functions

func NewTestConfig

func NewTestConfig(opts ...ConfigOption) *config.Config

NewTestConfig creates a generic test configuration backed by SQLite. Consuming services can override fields via functional options.

func NewTestDB

func NewTestDB(t testing.TB) *gorm.DB

NewTestDB creates an in-memory SQLite database connection for testing. The database is created fresh for each test and does not persist.

Types

type ConfigOption

type ConfigOption func(*config.Config)

ConfigOption is a functional option for configuring test config.

func WithEnvironment

func WithEnvironment(env string) ConfigOption

WithEnvironment sets the environment in test config.

func WithVersion

func WithVersion(version string) ConfigOption

WithVersion sets the version in test config.

Jump to

Keyboard shortcuts

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