Documentation
¶
Overview ¶
Package testenv provides unified, progressively-configured test environments for isolated filesystem tests. It creates temp directories for all four XDG categories (config, data, state, cache), sets the corresponding CLAWKER_*_DIR env vars, and optionally wires up a real config.Config and/or ProjectManager.
Usage:
// Just isolated dirs (storage tests): env := testenv.New(t) env.Dirs.Data // absolute path // With real config (config, socketbridge tests): env := testenv.New(t, testenv.WithConfig()) env.Config() // config.Config backed by temp dirs // With real project manager (project tests): env := testenv.New(t, testenv.WithProjectManager(nil)) env.ProjectManager() // project.ProjectManager env.Config() // also available — PM implies Config
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
Dirs IsolatedDirs
// contains filtered or unexported fields
}
Env is a unified test environment with isolated directories and optional higher-level capabilities (config, project manager).
func New ¶
New creates an isolated test environment. It:
- Creates temp directories for config, data, state, and cache
- Sets CLAWKER_CONFIG_DIR, CLAWKER_DATA_DIR, CLAWKER_STATE_DIR, CLAWKER_CACHE_DIR env vars (restored on test cleanup)
- Applies any options (WithConfig, WithProjectManager)
func (*Env) Config ¶
Config returns the config.Config. Panics if WithConfig (or WithProjectManager) was not passed to New.
func (*Env) ProjectManager ¶
func (e *Env) ProjectManager() project.ProjectManager
ProjectManager returns the project.ProjectManager. Panics if WithProjectManager was not passed to New.
type IsolatedDirs ¶
type IsolatedDirs struct {
Base string // temp root (parent of all dirs)
Config string // CLAWKER_CONFIG_DIR
Data string // CLAWKER_DATA_DIR
State string // CLAWKER_STATE_DIR
Cache string // CLAWKER_CACHE_DIR
}
IsolatedDirs holds the four XDG-style directory paths created for the test.
type Option ¶
Option configures an Env during construction.
func WithConfig ¶
func WithConfig() Option
WithConfig creates a real config.Config backed by the isolated directories. The config is available via env.Config().
func WithProjectManager ¶
func WithProjectManager(gitFactory project.GitManagerFactory) Option
WithProjectManager creates a real project.ProjectManager backed by the isolated directories. Implies WithConfig. Pass nil for gitFactory if worktree operations are not needed.