mocks

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 5 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 OpenAIClientMock added in v1.1.0

type OpenAIClientMock struct {
	// CreateChatCompletionFunc mocks the CreateChatCompletion method.
	CreateChatCompletionFunc func(contextMoqParam context.Context, chatCompletionRequest openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)
	// contains filtered or unexported fields
}

OpenAIClientMock is a mock implementation of lib.openAIClient.

func TestSomethingThatUsesopenAIClient(t *testing.T) {

	// make and configure a mocked lib.openAIClient
	mockedopenAIClient := &OpenAIClientMock{
		CreateChatCompletionFunc: func(contextMoqParam context.Context, chatCompletionRequest openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error) {
			panic("mock out the CreateChatCompletion method")
		},
	}

	// use mockedopenAIClient in code that requires lib.openAIClient
	// and then make assertions.

}

func (*OpenAIClientMock) CreateChatCompletion added in v1.1.0

func (mock *OpenAIClientMock) CreateChatCompletion(contextMoqParam context.Context, chatCompletionRequest openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)

CreateChatCompletion calls CreateChatCompletionFunc.

func (*OpenAIClientMock) CreateChatCompletionCalls added in v1.1.0

func (mock *OpenAIClientMock) CreateChatCompletionCalls() []struct {
	ContextMoqParam       context.Context
	ChatCompletionRequest openai.ChatCompletionRequest
}

CreateChatCompletionCalls gets all the calls that were made to CreateChatCompletion. check the length with:

len(mockedopenAIClient.CreateChatCompletionCalls())

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