mock

package
v0.0.0-...-971312d Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 6 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 interfaces.HTTPClient.

func TestSomethingThatUsesHTTPClient(t *testing.T) {

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

	// use mockedHTTPClient in code that requires interfaces.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 S3Mock

type S3Mock struct {
	// GetObjectFunc mocks the GetObject method.
	GetObjectFunc func(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	// contains filtered or unexported fields
}

S3Mock is a mock implementation of interfaces.S3.

func TestSomethingThatUsesS3(t *testing.T) {

	// make and configure a mocked interfaces.S3
	mockedS3 := &S3Mock{
		GetObjectFunc: func(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error) {
			panic("mock out the GetObject method")
		},
	}

	// use mockedS3 in code that requires interfaces.S3
	// and then make assertions.

}

func (*S3Mock) GetObject

func (mock *S3Mock) GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

GetObject calls GetObjectFunc.

func (*S3Mock) GetObjectCalls

func (mock *S3Mock) GetObjectCalls() []struct {
	Ctx    context.Context
	Params *s3.GetObjectInput
	OptFns []func(*s3.Options)
}

GetObjectCalls gets all the calls that were made to GetObject. Check the length with:

len(mockedS3.GetObjectCalls())

type SQSMock

type SQSMock struct {
	// DeleteMessageFunc mocks the DeleteMessage method.
	DeleteMessageFunc func(ctx context.Context, params *sqs.DeleteMessageInput, optFns ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error)

	// ReceiveMessageFunc mocks the ReceiveMessage method.
	ReceiveMessageFunc func(ctx context.Context, params *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)
	// contains filtered or unexported fields
}

SQSMock is a mock implementation of interfaces.SQS.

func TestSomethingThatUsesSQS(t *testing.T) {

	// make and configure a mocked interfaces.SQS
	mockedSQS := &SQSMock{
		DeleteMessageFunc: func(ctx context.Context, params *sqs.DeleteMessageInput, optFns ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error) {
			panic("mock out the DeleteMessage method")
		},
		ReceiveMessageFunc: func(ctx context.Context, params *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) {
			panic("mock out the ReceiveMessage method")
		},
	}

	// use mockedSQS in code that requires interfaces.SQS
	// and then make assertions.

}

func (*SQSMock) DeleteMessage

func (mock *SQSMock) DeleteMessage(ctx context.Context, params *sqs.DeleteMessageInput, optFns ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error)

DeleteMessage calls DeleteMessageFunc.

func (*SQSMock) DeleteMessageCalls

func (mock *SQSMock) DeleteMessageCalls() []struct {
	Ctx    context.Context
	Params *sqs.DeleteMessageInput
	OptFns []func(*sqs.Options)
}

DeleteMessageCalls gets all the calls that were made to DeleteMessage. Check the length with:

len(mockedSQS.DeleteMessageCalls())

func (*SQSMock) ReceiveMessage

func (mock *SQSMock) ReceiveMessage(ctx context.Context, params *sqs.ReceiveMessageInput, optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)

ReceiveMessage calls ReceiveMessageFunc.

func (*SQSMock) ReceiveMessageCalls

func (mock *SQSMock) ReceiveMessageCalls() []struct {
	Ctx    context.Context
	Params *sqs.ReceiveMessageInput
	OptFns []func(*sqs.Options)
}

ReceiveMessageCalls gets all the calls that were made to ReceiveMessage. Check the length with:

len(mockedSQS.ReceiveMessageCalls())

Jump to

Keyboard shortcuts

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