harness

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSOptions

type FSOptions struct {
	ProjectDir string // subdirectory name under base (default: "testproject")
}

FSOptions allows overriding the project directory name.

type Harness

type Harness struct {
	T       *testing.T
	Factory *cmdutil.Factory
}

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 (*Harness) NewIsolatedFS

func (h *Harness) NewIsolatedFS(opts *FSOptions) *SetupResult

NewIsolatedFS creates an isolated test environment.

Delegates XDG directory setup to testenv.New, then adds a project directory and chdirs into it (restored on cleanup).

func (*Harness) Run

func (h *Harness) Run(args ...string) *RunResult

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.

type RunResult

type RunResult struct {
	ExitCode int
	Err      error
}

RunResult holds the outcome of a CLI command execution.

type SetupResult

type SetupResult struct {
	BaseDir    string
	ProjectDir string
	ConfigDir  string
	DataDir    string
	StateDir   string
	CacheDir   string
}

SetupResult holds the resolved paths from NewIsolatedFS.

func (*SetupResult) Chdir

func (r *SetupResult) Chdir(t *testing.T, dir string)

Chdir changes the working directory and registers a cleanup to restore it to ProjectDir when the test ends.

Jump to

Keyboard shortcuts

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