Documentation
¶
Overview ¶
Package statedirtest provides the single hermetic environment helper for state-component tests (working-with-state.md §3.1). It points the full 8-var env set at a per-test temp dir so resolution for config and cache (the pillars with implemented resolvers today) never reaches the developer's real directories on any OS. Env coverage for the data pillar is ready ahead of the resolver API — XDG_STATE_HOME and %LOCALAPPDATA% are already pinned so that Data() (when it lands — working-with-state.md §7 rollout step 7) will be hermetic from day one. Secrets are keyring-backed and location-independent. (The set was 7-var at INT-310 delivery and grew to 8 on 2026-05-28 when the Data pillar's Path A backing added XDG_STATE_HOME.)
HOME-only isolation is a Windows real-dir leak: os.UserConfigDir reads %AppData% and os.UserCacheDir reads %LocalAppData%, neither of which is derived from %USERPROFILE%/HOME. The data pillar (§5.2) reads %LOCALAPPDATA% on Windows and $XDG_STATE_HOME on Linux; both are pinned here. This helper is the one definition of the list; no CLI re-derives it.
Not usable under t.Parallel: t.Setenv mutates process-global env and Go panics if it is called on a parallel test. Per-instance overrides are the parallel-safe alternative and remain a per-port choice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hermetic ¶
Hermetic isolates the full §3.1 8-var env set under t.TempDir() and returns the temp root. Every override is restored by t.Setenv's own cleanup.
Must NOT be called from a test that has called t.Parallel: t.Setenv mutates process-global env and Go panics in that case. Use a per-instance override for parallel tests instead.
Types ¶
This section is empty.