mocks

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 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 ConnectorMock

type ConnectorMock struct {
	// ConnectFunc mocks the Connect method.
	ConnectFunc func(ctx context.Context, host 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, host 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, host string, user string) (*executor.Remote, error)

Connect calls ConnectFunc.

func (*ConnectorMock) ConnectCalls

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

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

len(mockedConnector.ConnectCalls())

Jump to

Keyboard shortcuts

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