test

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	// an error that must be returned (if Func is not set)
	Err error
	// an output that must be returned (if Func is not set)
	Output string
	// a callback that will be executed instead of an actual shell command.
	Func func(*exec.Cmd, int) (string, error)
	// a last executed command
	LastCmd *exec.Cmd
	// a number of executed commands
	ExecutedCount int
	// what to return when calling ReadFile
	FileToRead []byte
	// last file that was written with WriteFile
	WrittenFileBytes []byte
	WrittenFilePath  string
}

Executor is a test implementation of command executor. Always returns the pre-configured results. Remembers the last executed command.

func (*Executor) Execute

func (c *Executor) Execute(ctx context.Context, cmd *exec.Cmd) ([]byte, error)

func (*Executor) ReadFile

func (c *Executor) ReadFile(ctx context.Context, path string) ([]byte, error)

func (*Executor) Run

func (c *Executor) Run(ctx context.Context, cmd *exec.Cmd) error

func (*Executor) WriteFile

func (c *Executor) WriteFile(ctx context.Context, path string, data []byte) error

Jump to

Keyboard shortcuts

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