testcontainer

package
v0.0.0-...-1bb6d08 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyConfigToEnv

func ApplyConfigToEnv(cfg any)

ApplyConfigToEnv exports the non-zero fields of a config section as the environment variables config.Init reads them back from, so a test hands over a config struct instead of spelling out every variable name.

A variable name is the upper-cased config path: the section name followed by one mapstructure tag per nesting level, joined by "_". The nested section config.Logger.HTTPBody therefore lands on LOGGER_HTTP_BODY_ENABLED.

Zero-valued fields are skipped so a partially filled section leaves the remaining framework defaults alone, which also means a false bool cannot be exported this way. Fields with no single environment representation, such as slices and maps, are skipped as well.

func SetupClickhouse

func SetupClickhouse() (config.Clickhouse, func() error, error)

SetupClickhouse prepares a clickhouse database and returns the configuration for building an application-held analytical instance with clickhouse.New, together with the function that releases it.

Unlike SetupDatabase it never points the framework default database at the container: clickhouse is an analytical instance held next to the default database, not a replacement for it, so tests build their own handle and pass it to DatabaseOn and AggregateOn.

func SetupDatabase

func SetupDatabase(dbType config.DBType) (func() error, error)

SetupDatabase prepares the database that dbType names and points the framework at it, returning the function that releases it. An empty dbType selects the framework default.

A database the framework can connect to but that has no preparation here is rejected rather than quietly replaced, so a test never runs against a different database than the one it asked for.

func SetupKafka

func SetupKafka() (func() error, error)

SetupKafka starts a kafka container of its own and points the framework at it, returning the function that terminates it.

Unlike the other services this one is dedicated even by default: kafka has no server-side namespace a shared container could hand out per test binary, so isolation would take a topic-prefix contract imposed on business code, which is not the framework's call to make. A container per binary keeps topics and consumer groups apart by construction.

func SetupRedis

func SetupRedis() (func() error, error)

SetupRedis prepares a redis database and points the framework at it, returning the function that releases it. Modules that keep sessions or cache entries need it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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