exectest

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 5 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 exectest provides test doubles for the exec package: a recording MockRunner and a FakeBin helper for tests that need the real exec path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakeBin

func FakeBin(t *testing.T, name, script string)

FakeBin installs a shell script named `name` in a temp directory and prepends that directory to PATH for the duration of test t.

Types

type Call

type Call struct {
	Name string
	Args []string
	Env  []string // nil for Run calls; set for RunEnv/RunDir calls
	Dir  string   // empty for Run/RunEnv calls; set for RunDir calls
}

Call records a single invocation of MockRunner.Run, RunEnv, or RunDir.

type MockRunner

type MockRunner struct {
	Calls []Call
	// contains filtered or unexported fields
}

MockRunner is an exec.Runner that records calls and returns canned responses.

func NewMockRunner

func NewMockRunner() *MockRunner

NewMockRunner constructs an empty MockRunner.

func (*MockRunner) QueueResponse

func (m *MockRunner) QueueResponse(stdout, stderr string, err error)

QueueResponse enqueues one response to be returned by the next Run/RunEnv call.

func (*MockRunner) Run

func (m *MockRunner) Run(name string, args ...string) (string, string, error)

Run records the call and returns the next queued response.

func (*MockRunner) RunDir

func (m *MockRunner) RunDir(dir string, env []string, name string, args ...string) (string, string, error)

RunDir records the call (including dir and env) and returns the next queued response.

func (*MockRunner) RunEnv

func (m *MockRunner) RunEnv(env []string, name string, args ...string) (string, string, error)

RunEnv records the call (including env) and returns the next queued response.

Jump to

Keyboard shortcuts

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