Documentation
¶
Index ¶
- func ApplyConfigToEnv(cfg any)
- func SetupClickhouse() (config.Clickhouse, func() error, error)
- func SetupDatabase(dbType config.DBType) (release func() error, afterMigrate func(), err error)
- func SetupKafka() (func() error, error)
- func SetupRedis() (func() error, error)
- func SetupStandaloneMySQL(database, username, password string) (config.MySQL, func() error, error)
- func SetupStandalonePostgres(database, username, password string) (config.Postgres, func() error, error)
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 ¶
SetupDatabase prepares the database that dbType names and points the framework at it, returning the function that releases it and the one to run once the framework has migrated it, see prepareSchemaTemplate. 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 ¶
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 ¶
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.
func SetupStandaloneMySQL ¶
SetupStandaloneMySQL starts a mysql container of its own with the given database name and credentials, and returns its connection settings without touching the process environment or the framework's default database. Tests use it for topologies the single default database cannot express — a non-replicating stand-in replica for routing assertions, a second instance for cross-instance behavior. The returned function terminates the container.
func SetupStandalonePostgres ¶
func SetupStandalonePostgres(database, username, password string) (config.Postgres, func() error, error)
SetupStandalonePostgres starts a postgres container of its own with the given database name and credentials, and returns its connection settings without touching the process environment or the framework's default database. Tests use it for topologies the single default database cannot express — a non-replicating stand-in replica for routing assertions, a second instance for cross-instance behavior. The returned function terminates the container.
Types ¶
This section is empty.