Help us shape the future of Go! Take the 2026 Go Developer Survey

runenvtest

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package runenvtest provides in-memory fakes of the runenv seams, assembled into a Rig, for testing code written against runenv.Dependencies.

Index

Constants

View Source
const (
	EnvRunnerTemp         = "RUNNER_TEMP=/tmp/rt"
	EnvDockerContextEmpty = "DOCKER_CONTEXT="
)

Environment entries shared by the runner and docker-wsl tests.

Variables

This section is empty.

Functions

func CodesOf

func CodesOf(err error) []runenv.Code

codesOf lists the Code of every StageError in err, including joined errors.

Types

type FakeClock

type FakeClock struct{ Step time.Duration }

fakeClock reports a fixed elapsed time and never sleeps.

func (FakeClock) Now

func (c FakeClock) Now() time.Time

func (FakeClock) Since

func (c FakeClock) Since(time.Time) time.Duration

func (FakeClock) Sleep

type MemFiles

type MemFiles struct {
	Data  map[string][]byte
	Modes map[string]fs.FileMode
	// writes lists the paths of successful WriteFile calls, in order.
	Writes []string
	// failWrite makes WriteFile fail for a path; failAppend makes AppendFile fail.
	FailWrite  map[string]error
	FailAppend error
	// contains filtered or unexported fields
}

memFiles is an in-memory FileStore keyed by host-native path.

func NewMemFiles

func NewMemFiles() *MemFiles

func (*MemFiles) AppendFile

func (m *MemFiles) AppendFile(name string, data []byte, perm fs.FileMode) error

func (*MemFiles) Has

func (m *MemFiles) Has(name string) bool

func (*MemFiles) MkdirAll

func (m *MemFiles) MkdirAll(string, fs.FileMode) error

func (*MemFiles) ReadFile

func (m *MemFiles) ReadFile(name string) ([]byte, error)

func (*MemFiles) Remove

func (m *MemFiles) Remove(name string) error

func (*MemFiles) RemoveAll

func (m *MemFiles) RemoveAll(path string) error

RemoveAll deletes path and everything beneath it.

func (*MemFiles) Stat

func (m *MemFiles) Stat(name string) (fs.FileInfo, error)

func (*MemFiles) Text

func (m *MemFiles) Text(name string) string

text returns the file's content, or "" when it does not exist.

func (*MemFiles) Under

func (m *MemFiles) Under(dir string) []string

under lists, sorted, the files strictly beneath dir.

func (*MemFiles) WriteFile

func (m *MemFiles) WriteFile(name string, data []byte, perm fs.FileMode) error

type Rig

type Rig struct {
	*runenv.Dependencies
	Runner *fakeRunner
	FS     *MemFiles
	Output *bytes.Buffer
}

Rig is Dependencies over fakes plus handles to the fakes.

func NewRig

func NewRig(goos string, env []string) *Rig

Jump to

Keyboard shortcuts

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