Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness provides an isolated filesystem environment for integration tests. It creates temp directories, sets XDG env vars, registers a project, and optionally persists config — all driven by what the caller wired into the Factory.
func New ¶ added in v0.3.0
New creates an isolated test environment and returns a Harness.
The caller passes a pre-built *cmdutil.Factory. The harness:
- Creates temp dirs for config, data, state, and project
- Sets CLAWKER_CONFIG_DIR, CLAWKER_DATA_DIR, CLAWKER_STATE_DIR via t.Setenv
- If f.ProjectManager is set (and not opted out): registers "testrepo" at projectDir
- Chdirs to projectDir (restored on cleanup)
func (*Harness) ProjectDir ¶
ProjectDir returns the path to the isolated project directory.
func (*Harness) Run ¶ added in v0.3.0
Run executes a CLI command through the full root.NewCmdRoot Cobra pipeline using the stored factory. IO is whatever the caller wired into the factory.
func (*Harness) WriteConfig ¶ added in v0.3.0
WriteConfig persists a config.Config to disk by calling Write() on its project and settings stores. Call this after New() to persist config that was created using the harness's env vars.
type Option ¶ added in v0.3.0
type Option func(*options)
Option configures harness behavior.
func WithConfig ¶
WithConfig persists a config.Config to disk via its store Write() methods. The Config must be created AFTER harness.New() sets env vars — pass it via a closure or create it inside the test after New() returns... but that's too late. Instead, create Config lazily: the factory's Config closure will resolve after env vars are set. Use WriteConfig() on the harness after New().
func WithoutProjectRegistered ¶ added in v0.3.0
func WithoutProjectRegistered() Option
WithoutProjectRegistered skips automatic project registration. Use this for testing init/project-init commands that do their own registration.