fake

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 14 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 fake is a test-only executor over memfs and scripted commands.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownCommand = errors.New("memexecutor: no script for command")

ErrUnknownCommand reports a command with no script.

Functions

func NewClient

func NewClient(t testing.TB, e Executor) *grpc.ClientConn

NewClient serves e in process for the test's lifetime.

Types

type Executor

type Executor struct {
	Files          *memfs.Workspace
	FileOptions    []files.Option
	Commands       *Runner
	CommandOptions []commands.Option
}

Executor configures NewClient; a nil service stays unregistered.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner is a scripted commands.Runner.

func NewRunner

func NewRunner() *Runner

NewRunner returns an empty Runner.

func (*Runner) Refuse

func (r *Runner) Refuse(command string, err error)

Refuse fails every start of command with err.

func (*Runner) Running

func (r *Runner) Running() int

Running counts unfinished scripts.

func (*Runner) Script

func (r *Runner) Script(command string, s Script)

Script plays s for command.

func (*Runner) Start

func (r *Runner) Start(
	ctx context.Context,
	command string,
	stdout io.Writer,
	stderr io.Writer,
) (commands.Process, error)

Start implements commands.Runner.

type Script

type Script func(ctx context.Context, stdout, stderr io.Writer) commands.Exit

Script plays a command until it returns.

func Block

func Block(ready string) Script

Block writes ready to stdout, then waits for ctx.

func Exit

func Exit(stdout, stderr string, code int) Script

Exit writes stdout and stderr, then exits with code.

func OutcomeUnknown

func OutcomeUnknown(s Script) Script

OutcomeUnknown plays s without confirming cleanup.

func Stream

func Stream(next <-chan struct{}, chunks ...string) Script

Stream writes one chunk to stdout per receive from next, then exits 0.

Jump to

Keyboard shortcuts

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