mocks

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectorMock

type ConnectorMock struct {
	// ConnectFunc mocks the Connect method.
	ConnectFunc func(ctx context.Context, hostAddr string, hostName string, user string) (*executor.Remote, error)
	// contains filtered or unexported fields
}

ConnectorMock is a mock implementation of runner.Connector.

func TestSomethingThatUsesConnector(t *testing.T) {

	// make and configure a mocked runner.Connector
	mockedConnector := &ConnectorMock{
		ConnectFunc: func(ctx context.Context, hostAddr string, hostName string, user string) (*executor.Remote, error) {
			panic("mock out the Connect method")
		},
	}

	// use mockedConnector in code that requires runner.Connector
	// and then make assertions.

}

func (*ConnectorMock) Connect

func (mock *ConnectorMock) Connect(ctx context.Context, hostAddr string, hostName string, user string) (*executor.Remote, error)

Connect calls ConnectFunc.

func (*ConnectorMock) ConnectCalls

func (mock *ConnectorMock) ConnectCalls() []struct {
	Ctx      context.Context
	HostAddr string
	HostName string
	User     string
}

ConnectCalls gets all the calls that were made to Connect. Check the length with:

len(mockedConnector.ConnectCalls())

type PlaybookMock added in v1.6.0

type PlaybookMock struct {
	// AllSecretValuesFunc mocks the AllSecretValues method.
	AllSecretValuesFunc func() []string

	// AllTasksFunc mocks the AllTasks method.
	AllTasksFunc func() []config.Task

	// TargetHostsFunc mocks the TargetHosts method.
	TargetHostsFunc func(name string) ([]config.Destination, error)

	// TaskFunc mocks the Task method.
	TaskFunc func(name string) (*config.Task, error)

	// UpdateTasksTargetsFunc mocks the UpdateTasksTargets method.
	UpdateTasksTargetsFunc func(vars map[string]string)
	// contains filtered or unexported fields
}

PlaybookMock is a mock implementation of runner.Playbook.

func TestSomethingThatUsesPlaybook(t *testing.T) {

	// make and configure a mocked runner.Playbook
	mockedPlaybook := &PlaybookMock{
		AllSecretValuesFunc: func() []string {
			panic("mock out the AllSecretValues method")
		},
		AllTasksFunc: func() []config.Task {
			panic("mock out the AllTasks method")
		},
		TargetHostsFunc: func(name string) ([]config.Destination, error) {
			panic("mock out the TargetHosts method")
		},
		TaskFunc: func(name string) (*config.Task, error) {
			panic("mock out the Task method")
		},
		UpdateTasksTargetsFunc: func(vars map[string]string)  {
			panic("mock out the UpdateTasksTargets method")
		},
	}

	// use mockedPlaybook in code that requires runner.Playbook
	// and then make assertions.

}

func (*PlaybookMock) AllSecretValues added in v1.6.0

func (mock *PlaybookMock) AllSecretValues() []string

AllSecretValues calls AllSecretValuesFunc.

func (*PlaybookMock) AllSecretValuesCalls added in v1.6.0

func (mock *PlaybookMock) AllSecretValuesCalls() []struct {
}

AllSecretValuesCalls gets all the calls that were made to AllSecretValues. Check the length with:

len(mockedPlaybook.AllSecretValuesCalls())

func (*PlaybookMock) AllTasks added in v1.6.0

func (mock *PlaybookMock) AllTasks() []config.Task

AllTasks calls AllTasksFunc.

func (*PlaybookMock) AllTasksCalls added in v1.6.0

func (mock *PlaybookMock) AllTasksCalls() []struct {
}

AllTasksCalls gets all the calls that were made to AllTasks. Check the length with:

len(mockedPlaybook.AllTasksCalls())

func (*PlaybookMock) TargetHosts added in v1.6.0

func (mock *PlaybookMock) TargetHosts(name string) ([]config.Destination, error)

TargetHosts calls TargetHostsFunc.

func (*PlaybookMock) TargetHostsCalls added in v1.6.0

func (mock *PlaybookMock) TargetHostsCalls() []struct {
	Name string
}

TargetHostsCalls gets all the calls that were made to TargetHosts. Check the length with:

len(mockedPlaybook.TargetHostsCalls())

func (*PlaybookMock) Task added in v1.6.0

func (mock *PlaybookMock) Task(name string) (*config.Task, error)

Task calls TaskFunc.

func (*PlaybookMock) TaskCalls added in v1.6.0

func (mock *PlaybookMock) TaskCalls() []struct {
	Name string
}

TaskCalls gets all the calls that were made to Task. Check the length with:

len(mockedPlaybook.TaskCalls())

func (*PlaybookMock) UpdateTasksTargets added in v1.6.0

func (mock *PlaybookMock) UpdateTasksTargets(vars map[string]string)

UpdateTasksTargets calls UpdateTasksTargetsFunc.

func (*PlaybookMock) UpdateTasksTargetsCalls added in v1.6.0

func (mock *PlaybookMock) UpdateTasksTargetsCalls() []struct {
	Vars map[string]string
}

UpdateTasksTargetsCalls gets all the calls that were made to UpdateTasksTargets. Check the length with:

len(mockedPlaybook.UpdateTasksTargetsCalls())

Jump to

Keyboard shortcuts

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