mocks

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 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 HTTPClientMock

type HTTPClientMock struct {
	// DoFunc mocks the Do method.
	DoFunc func(req *http.Request) (*http.Response, error)
	// contains filtered or unexported fields
}

HTTPClientMock is a mock implementation of lib.HTTPClient.

func TestSomethingThatUsesHTTPClient(t *testing.T) {

	// make and configure a mocked lib.HTTPClient
	mockedHTTPClient := &HTTPClientMock{
		DoFunc: func(req *http.Request) (*http.Response, error) {
			panic("mock out the Do method")
		},
	}

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

}

func (*HTTPClientMock) Do

func (mock *HTTPClientMock) Do(req *http.Request) (*http.Response, error)

Do calls DoFunc.

func (*HTTPClientMock) DoCalls

func (mock *HTTPClientMock) DoCalls() []struct {
	Req *http.Request
}

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

len(mockedHTTPClient.DoCalls())

type SampleUpdaterMock

type SampleUpdaterMock struct {
	// AppendFunc mocks the Append method.
	AppendFunc func(msg string) error

	// ReaderFunc mocks the Reader method.
	ReaderFunc func() (io.ReadCloser, error)
	// contains filtered or unexported fields
}

SampleUpdaterMock is a mock implementation of lib.SampleUpdater.

func TestSomethingThatUsesSampleUpdater(t *testing.T) {

	// make and configure a mocked lib.SampleUpdater
	mockedSampleUpdater := &SampleUpdaterMock{
		AppendFunc: func(msg string) error {
			panic("mock out the Append method")
		},
		ReaderFunc: func() (io.ReadCloser, error) {
			panic("mock out the Reader method")
		},
	}

	// use mockedSampleUpdater in code that requires lib.SampleUpdater
	// and then make assertions.

}

func (*SampleUpdaterMock) Append

func (mock *SampleUpdaterMock) Append(msg string) error

Append calls AppendFunc.

func (*SampleUpdaterMock) AppendCalls

func (mock *SampleUpdaterMock) AppendCalls() []struct {
	Msg string
}

AppendCalls gets all the calls that were made to Append. Check the length with:

len(mockedSampleUpdater.AppendCalls())

func (*SampleUpdaterMock) Reader

func (mock *SampleUpdaterMock) Reader() (io.ReadCloser, error)

Reader calls ReaderFunc.

func (*SampleUpdaterMock) ReaderCalls

func (mock *SampleUpdaterMock) ReaderCalls() []struct {
}

ReaderCalls gets all the calls that were made to Reader. Check the length with:

len(mockedSampleUpdater.ReaderCalls())

Jump to

Keyboard shortcuts

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