testdirs

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 3 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 testdirs provides per-process fallback directories for the CLI's on-disk config, cache, and credential surfaces when running inside `go test`.

Production code resolves these surfaces relative to the user's home directory (~/.config/entire, ~/.cache/entire, the OS keyring). A test that forgets to set the explicit override (ENTIRE_CONFIG_DIR, XDG_CACHE_HOME, ENTIRE_TOKEN_STORE, ...) would silently read and write the developer's real configuration — real auth contexts have been polluted with test fixtures this way. Dir gives the resolution functions a safe default under test: a throwaway directory under os.TempDir, never the real config/cache locations. (os.TempDir respects TMPDIR and may itself live under $HOME; the guarantee is "not ~/.config/entire or ~/.cache/entire", not "outside the home directory".)

The fallback directory is per-process, not per-test: all tests in one test binary share it. Tests that need isolation from each other must still set the explicit override (e.g. t.Setenv("ENTIRE_CONFIG_DIR", t.TempDir())) — this package only guarantees that an unisolated test can never touch real user state.

testing.Testing() is false in subprocesses, so spawned `entire` binaries are NOT covered by this fallback. Harnesses that spawn the real binary (integration tests, e2e) must export the override env vars instead — see their TestMain functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(surface string) (string, bool)

Dir returns a stable per-process directory for the named surface (e.g. "config", "cache", "tokenstore") when running under `go test`, creating it on first use. ok is false in production binaries — testing.Testing() is false there — and when the directory cannot be created; callers then fall back to their normal home-relative resolution.

Types

This section is empty.

Jump to

Keyboard shortcuts

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