testutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr returns a pointer to v. v is the boolean value to take the address of.

func ForbidExec added in v0.14.0

func ForbidExec(t *testing.T, target *func(string, []string, []string) error)

ForbidExec replaces target with a test failure and restores the original handoff when the test completes.

func WithWorkingDir

func WithWorkingDir(t *testing.T, dir string, fn func())

WithWorkingDir runs fn with dir as the current working directory and restores the previous directory. t is the active test; dir is the temporary working directory for fn.

func WriteStub

func WriteStub(t *testing.T, dir string, name string)

WriteStub writes an executable shell stub that exits successfully. t is the active test; dir is the output directory; name is the executable file name.

func WriteStubExpectArg

func WriteStubExpectArg(t *testing.T, dir string, name string, expectedArg string)

WriteStubExpectArg writes an executable shell stub that succeeds only when expectedArg is present. t is the active test; dir is the output directory; name is the executable file name.

func WriteStubWithExit

func WriteStubWithExit(t *testing.T, dir string, name string, exitCode int)

WriteStubWithExit writes an executable shell stub that exits with the provided code. t is the active test; dir is the output directory; name is the executable file name.

Types

type ExecCall added in v0.14.0

type ExecCall struct {
	Called bool
	Path   string
	Argv   []string
	Env    []string
}

ExecCall records one captured executable handoff.

func CaptureExec added in v0.14.0

func CaptureExec(t *testing.T, target *func(string, []string, []string) error, err error) *ExecCall

CaptureExec replaces target with a one-call capture seam that returns err. It restores the original handoff when the test completes.

func (*ExecCall) AssertCalled added in v0.14.0

func (call *ExecCall) AssertCalled(t *testing.T, wantPath string, wantArgv []string)

AssertCalled verifies that the executable handoff occurred once with the expected path and argument vector.

Jump to

Keyboard shortcuts

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