statedirtest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package statedirtest provides the single hermetic environment helper for state-component tests (working-with-state.md §3.1). It points the full 7-var env set at a per-test temp dir so os.UserConfigDir / os.UserCacheDir never resolve to the developer's real directories on any OS.

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

func Hermetic(t *testing.T) string

Hermetic isolates the full §3.1 7-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.

Jump to

Keyboard shortcuts

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