testutils

package
v0.0.0-...-8019b93 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrorMatch

func AssertErrorMatch(t *testing.T, msg string, testErr error)

func AssertNoError

func AssertNoError(t *testing.T, err error)

func ErrorMatch

func ErrorMatch(t *testing.T, msg string, testErr error) bool

ErrorMatch returns true if an error matches the required string.

e.g. ErrorMatch(t, "failed to open", err) would return true if the err passed in had a string that matched.

The message can be a regular expression, and if this fails to compile, then the test will fail.

Types

type ErrorStack

type ErrorStack struct {
	Errors []error
	sync.Mutex
}

func NewErrors

func NewErrors() *ErrorStack

func (*ErrorStack) Pop

func (s *ErrorStack) Pop() error

func (*ErrorStack) Push

func (s *ErrorStack) Push(err error)

type Execution

type Execution struct {
	BaseDir string
	Command string
	Args    []string
}

type MockExecutor

type MockExecutor struct {
	Outputs  *OutputStack
	Errors   *ErrorStack
	Executed []Execution
}

func NewMockExecutor

func NewMockExecutor(outputs ...[]byte) *MockExecutor

func (*MockExecutor) AssertCommandsExecuted

func (m *MockExecutor) AssertCommandsExecuted(t *testing.T, want []Execution)

func (*MockExecutor) Execute

func (m *MockExecutor) Execute(basedir, command string, args ...string) ([]byte, error)

type OutputStack

type OutputStack struct {
	Outputs [][]byte
	sync.Mutex
}

func NewOutputs

func NewOutputs(o ...[]byte) *OutputStack

func (*OutputStack) Pop

func (s *OutputStack) Pop() []byte

Jump to

Keyboard shortcuts

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