executiltest

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package executiltest provides a scripted executil.Executor test double.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Cmd  string
	Dir  string
	Args []string
}

Call records one executor invocation.

type Exec

type Exec struct {
	Responses []Response
	// contains filtered or unexported fields
}

Exec is a scripted executil.Executor: every invocation records a Call and consumes the next Response (zero-value results once the script runs out, so an unscripted Exec is a silent no-op stub). It also implements the RunOutputDir seam for separated stdout/stderr. Safe for concurrent use.

func (*Exec) Calls

func (e *Exec) Calls() []Call

Calls returns the recorded invocations in call order.

func (*Exec) Run

func (e *Exec) Run(_ context.Context, cmd string, args ...string) ([]byte, error)

Run returns the scripted response's combined output.

func (*Exec) RunDir

func (e *Exec) RunDir(_ context.Context, dir, cmd string, args ...string) ([]byte, error)

RunDir behaves like Run and records the directory.

func (*Exec) RunDirStream

func (e *Exec) RunDirStream(_ context.Context, dir string, stdout, stderr io.Writer, cmd string, args ...string) error

RunDirStream behaves like RunStream and records the directory.

func (*Exec) RunOutputDir added in v0.56.0

func (e *Exec) RunOutputDir(_ context.Context, dir, cmd string, args ...string) ([]byte, []byte, error)

RunOutputDir returns the scripted response's stdout and stderr separately and records the directory.

func (*Exec) RunStream

func (e *Exec) RunStream(_ context.Context, stdout, stderr io.Writer, cmd string, args ...string) error

RunStream writes the scripted response to the provided writers.

type Response

type Response struct {
	Out    []byte
	Stderr []byte
	Err    error
}

Response scripts the result of one invocation, consumed in call order.

Jump to

Keyboard shortcuts

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