mocks

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: ISC Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClientMock

type HTTPClientMock struct {
	// DoFunc mocks the Do method.
	DoFunc func(ctx context.Context, method string, endpoint string, expStatus int, req interface{}, out interface{}) error
	// contains filtered or unexported fields
}

HTTPClientMock is a mock implementation of data.HTTPClient.

func TestSomethingThatUsesHTTPClient(t *testing.T) {

	// make and configure a mocked data.HTTPClient
	mockedHTTPClient := &HTTPClientMock{
		DoFunc: func(ctx context.Context, method string, endpoint string, expStatus int, req interface{}, out interface{}) error {
			panic("mock out the Do method")
		},
	}

	// use mockedHTTPClient in code that requires data.HTTPClient
	// and then make assertions.

}

func (*HTTPClientMock) Do

func (mock *HTTPClientMock) Do(ctx context.Context, method string, endpoint string, expStatus int, req interface{}, out interface{}) error

Do calls DoFunc.

func (*HTTPClientMock) DoCalls

func (mock *HTTPClientMock) DoCalls() []struct {
	Ctx       context.Context
	Method    string
	Endpoint  string
	ExpStatus int
	Req       interface{}
	Out       interface{}
}

DoCalls gets all the calls that were made to Do. Check the length with:

len(mockedHTTPClient.DoCalls())

Jump to

Keyboard shortcuts

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