mocks

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0, 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 ExecutorMock

type ExecutorMock struct {
	// ExecuteFunc mocks the Execute method.
	ExecuteFunc func(command string, args []string) ([]byte, error)
	// contains filtered or unexported fields
}

ExecutorMock is a mock implementation of executor.Executor.

func TestSomethingThatUsesExecutor(t *testing.T) {

	// make and configure a mocked executor.Executor
	mockedExecutor := &ExecutorMock{
		ExecuteFunc: func(command string, args []string) ([]byte, error) {
			panic("mock out the Execute method")
		},
	}

	// use mockedExecutor in code that requires executor.Executor
	// and then make assertions.

}

func (*ExecutorMock) Execute

func (mock *ExecutorMock) Execute(command string, args []string) ([]byte, error)

Execute calls ExecuteFunc.

func (*ExecutorMock) ExecuteCalls

func (mock *ExecutorMock) ExecuteCalls() []struct {
	Command string
	Args    []string
}

ExecuteCalls gets all the calls that were made to Execute. Check the length with:

len(mockedExecutor.ExecuteCalls())

Jump to

Keyboard shortcuts

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