mocks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigMock

type ConfigMock struct {
	// GetTaskCommandFunc mocks the GetTaskCommand method.
	GetTaskCommandFunc func(name string) (string, bool)
	// contains filtered or unexported fields
}

ConfigMock is a mock implementation of server.Config.

func TestSomethingThatUsesConfig(t *testing.T) {

	// make and configure a mocked server.Config
	mockedConfig := &ConfigMock{
		GetTaskCommandFunc: func(name string) (string, bool) {
			panic("mock out the GetTaskCommand method")
		},
	}

	// use mockedConfig in code that requires server.Config
	// and then make assertions.

}

func (*ConfigMock) GetTaskCommand

func (mock *ConfigMock) GetTaskCommand(name string) (string, bool)

GetTaskCommand calls GetTaskCommandFunc.

func (*ConfigMock) GetTaskCommandCalls

func (mock *ConfigMock) GetTaskCommandCalls() []struct {
	Name string
}

GetTaskCommandCalls gets all the calls that were made to GetTaskCommand. Check the length with:

len(mockedConfig.GetTaskCommandCalls())

type RunnerMock

type RunnerMock struct {
	// RunFunc mocks the Run method.
	RunFunc func(ctx context.Context, command string, logWriter io.Writer) error
	// contains filtered or unexported fields
}

RunnerMock is a mock implementation of server.Runner.

func TestSomethingThatUsesRunner(t *testing.T) {

	// make and configure a mocked server.Runner
	mockedRunner := &RunnerMock{
		RunFunc: func(ctx context.Context, command string, logWriter io.Writer) error {
			panic("mock out the Run method")
		},
	}

	// use mockedRunner in code that requires server.Runner
	// and then make assertions.

}

func (*RunnerMock) Run

func (mock *RunnerMock) Run(ctx context.Context, command string, logWriter io.Writer) error

Run calls RunFunc.

func (*RunnerMock) RunCalls

func (mock *RunnerMock) RunCalls() []struct {
	Ctx       context.Context
	Command   string
	LogWriter io.Writer
}

RunCalls gets all the calls that were made to Run. Check the length with:

len(mockedRunner.RunCalls())

Jump to

Keyboard shortcuts

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