configtest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configtest provides config-singleton setup helpers for tests. Kept separate from internal/testutil to avoid an import cycle: testutil is imported by config's own internal test suite, but this helper depends on internal/config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(overrides ...map[string]any) *config.Config

Setup seeds the process-wide config singleton with defaults plus any caller-supplied overrides, registers a DeferCleanup to reset the singleton, and returns the resulting *config.Config.

The data_dir key is automatically pointed at a Ginkgo-managed temp directory because config validation requires it to exist on disk. Overrides merge on top of defaults + the tmp data_dir — they use the same nested map shape as the YAML config file.

Intended for use in BeforeEach or BeforeSuite:

BeforeEach(func() { configtest.Setup(map[string]any{
    "auth": map[string]any{
        "session_secret": "test-secret",
        "session_ttl":    "1h",
    },
}) })

func SetupFile

func SetupFile(overrides ...map[string]any) *config.Config

SetupFile mirrors Setup but writes a YAML file to a temp dir and calls config.Load(path), so config.Update has a backing file to write back to. Required whenever anything under test can reach config.Update — a single mutating endpoint anywhere in a wired-app suite is enough, since Update returns ErrNoPath without a file. Setup suffices for read-only tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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