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 ¶
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 ¶
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.