mocks

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: MIT 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 tgspam.HTTPClient.

func TestSomethingThatUsesHTTPClient(t *testing.T) {

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

	// use mockedHTTPClient in code that requires tgspam.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())

func (*HTTPClientMock) ResetCalls

func (mock *HTTPClientMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*HTTPClientMock) ResetDoCalls

func (mock *HTTPClientMock) ResetDoCalls()

ResetDoCalls reset all the calls that were made to Do.

type OpenAIClientMock

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 tgspam.openAIClient.

func TestSomethingThatUsesopenAIClient(t *testing.T) {

	// make and configure a mocked tgspam.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 tgspam.openAIClient
	// and then make assertions.

}

func (*OpenAIClientMock) CreateChatCompletion

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

CreateChatCompletion calls CreateChatCompletionFunc.

func (*OpenAIClientMock) CreateChatCompletionCalls

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 tgspam.SampleUpdater.

func TestSomethingThatUsesSampleUpdater(t *testing.T) {

	// make and configure a mocked tgspam.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 tgspam.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())

func (*SampleUpdaterMock) ResetAppendCalls

func (mock *SampleUpdaterMock) ResetAppendCalls()

ResetAppendCalls reset all the calls that were made to Append.

func (*SampleUpdaterMock) ResetCalls

func (mock *SampleUpdaterMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*SampleUpdaterMock) ResetReaderCalls

func (mock *SampleUpdaterMock) ResetReaderCalls()

ResetReaderCalls reset all the calls that were made to Reader.

type UserStorageMock

type UserStorageMock struct {
	// DeleteFunc mocks the Delete method.
	DeleteFunc func(id string) error

	// ReadFunc mocks the Read method.
	ReadFunc func() ([]approved.UserInfo, error)

	// WriteFunc mocks the Write method.
	WriteFunc func(au approved.UserInfo) error
	// contains filtered or unexported fields
}

UserStorageMock is a mock implementation of tgspam.UserStorage.

func TestSomethingThatUsesUserStorage(t *testing.T) {

	// make and configure a mocked tgspam.UserStorage
	mockedUserStorage := &UserStorageMock{
		DeleteFunc: func(id string) error {
			panic("mock out the Delete method")
		},
		ReadFunc: func() ([]approved.UserInfo, error) {
			panic("mock out the Read method")
		},
		WriteFunc: func(au approved.UserInfo) error {
			panic("mock out the Write method")
		},
	}

	// use mockedUserStorage in code that requires tgspam.UserStorage
	// and then make assertions.

}

func (*UserStorageMock) Delete

func (mock *UserStorageMock) Delete(id string) error

Delete calls DeleteFunc.

func (*UserStorageMock) DeleteCalls

func (mock *UserStorageMock) DeleteCalls() []struct {
	ID string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedUserStorage.DeleteCalls())

func (*UserStorageMock) Read

func (mock *UserStorageMock) Read() ([]approved.UserInfo, error)

Read calls ReadFunc.

func (*UserStorageMock) ReadCalls

func (mock *UserStorageMock) ReadCalls() []struct {
}

ReadCalls gets all the calls that were made to Read. Check the length with:

len(mockedUserStorage.ReadCalls())

func (*UserStorageMock) ResetCalls

func (mock *UserStorageMock) ResetCalls()

ResetCalls reset all the calls that were made to all mocked methods.

func (*UserStorageMock) ResetDeleteCalls

func (mock *UserStorageMock) ResetDeleteCalls()

ResetDeleteCalls reset all the calls that were made to Delete.

func (*UserStorageMock) ResetReadCalls

func (mock *UserStorageMock) ResetReadCalls()

ResetReadCalls reset all the calls that were made to Read.

func (*UserStorageMock) ResetWriteCalls

func (mock *UserStorageMock) ResetWriteCalls()

ResetWriteCalls reset all the calls that were made to Write.

func (*UserStorageMock) Write

func (mock *UserStorageMock) Write(au approved.UserInfo) error

Write calls WriteFunc.

func (*UserStorageMock) WriteCalls

func (mock *UserStorageMock) WriteCalls() []struct {
	Au approved.UserInfo
}

WriteCalls gets all the calls that were made to Write. Check the length with:

len(mockedUserStorage.WriteCalls())

Jump to

Keyboard shortcuts

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