mocks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 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 BotMock

type BotMock struct {
	// OnMessageFunc mocks the OnMessage method.
	OnMessageFunc func(msg bot.Message) bot.Response
	// contains filtered or unexported fields
}

BotMock is a mock implementation of events.Bot.

func TestSomethingThatUsesBot(t *testing.T) {

	// make and configure a mocked events.Bot
	mockedBot := &BotMock{
		OnMessageFunc: func(msg bot.Message) bot.Response {
			panic("mock out the OnMessage method")
		},
	}

	// use mockedBot in code that requires events.Bot
	// and then make assertions.

}

func (*BotMock) OnMessage

func (mock *BotMock) OnMessage(msg bot.Message) bot.Response

OnMessage calls OnMessageFunc.

func (*BotMock) OnMessageCalls

func (mock *BotMock) OnMessageCalls() []struct {
	Msg bot.Message
}

OnMessageCalls gets all the calls that were made to OnMessage. Check the length with:

len(mockedBot.OnMessageCalls())

func (*BotMock) ResetCalls

func (mock *BotMock) ResetCalls()

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

func (*BotMock) ResetOnMessageCalls

func (mock *BotMock) ResetOnMessageCalls()

ResetOnMessageCalls reset all the calls that were made to OnMessage.

type SpamLoggerMock

type SpamLoggerMock struct {
	// SaveFunc mocks the Save method.
	SaveFunc func(msg *bot.Message, response *bot.Response)
	// contains filtered or unexported fields
}

SpamLoggerMock is a mock implementation of events.SpamLogger.

func TestSomethingThatUsesSpamLogger(t *testing.T) {

	// make and configure a mocked events.SpamLogger
	mockedSpamLogger := &SpamLoggerMock{
		SaveFunc: func(msg *bot.Message, response *bot.Response)  {
			panic("mock out the Save method")
		},
	}

	// use mockedSpamLogger in code that requires events.SpamLogger
	// and then make assertions.

}

func (*SpamLoggerMock) ResetCalls

func (mock *SpamLoggerMock) ResetCalls()

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

func (*SpamLoggerMock) ResetSaveCalls

func (mock *SpamLoggerMock) ResetSaveCalls()

ResetSaveCalls reset all the calls that were made to Save.

func (*SpamLoggerMock) Save

func (mock *SpamLoggerMock) Save(msg *bot.Message, response *bot.Response)

Save calls SaveFunc.

func (*SpamLoggerMock) SaveCalls

func (mock *SpamLoggerMock) SaveCalls() []struct {
	Msg      *bot.Message
	Response *bot.Response
}

SaveCalls gets all the calls that were made to Save. Check the length with:

len(mockedSpamLogger.SaveCalls())

type SpamRestMock

type SpamRestMock struct {
	// UnbanURLFunc mocks the UnbanURL method.
	UnbanURLFunc func(userID int64) string
	// contains filtered or unexported fields
}

SpamRestMock is a mock implementation of events.SpamWeb.

func TestSomethingThatUsesSpamRest(t *testing.T) {

	// make and configure a mocked events.SpamWeb
	mockedSpamRest := &SpamRestMock{
		UnbanURLFunc: func(userID int64) string {
			panic("mock out the UnbanURL method")
		},
	}

	// use mockedSpamRest in code that requires events.SpamWeb
	// and then make assertions.

}

func (*SpamRestMock) ResetCalls

func (mock *SpamRestMock) ResetCalls()

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

func (*SpamRestMock) ResetUnbanURLCalls

func (mock *SpamRestMock) ResetUnbanURLCalls()

ResetUnbanURLCalls reset all the calls that were made to UnbanURL.

func (*SpamRestMock) UnbanURL

func (mock *SpamRestMock) UnbanURL(userID int64) string

UnbanURL calls UnbanURLFunc.

func (*SpamRestMock) UnbanURLCalls

func (mock *SpamRestMock) UnbanURLCalls() []struct {
	UserID int64
}

UnbanURLCalls gets all the calls that were made to UnbanURL. Check the length with:

len(mockedSpamRest.UnbanURLCalls())

type TbAPIMock

type TbAPIMock struct {
	// GetChatFunc mocks the GetChat method.
	GetChatFunc func(config tbapi.ChatInfoConfig) (tbapi.Chat, error)

	// GetUpdatesChanFunc mocks the GetUpdatesChan method.
	GetUpdatesChanFunc func(config tbapi.UpdateConfig) tbapi.UpdatesChannel

	// RequestFunc mocks the Request method.
	RequestFunc func(c tbapi.Chattable) (*tbapi.APIResponse, error)

	// SendFunc mocks the Send method.
	SendFunc func(c tbapi.Chattable) (tbapi.Message, error)
	// contains filtered or unexported fields
}

TbAPIMock is a mock implementation of events.TbAPI.

func TestSomethingThatUsesTbAPI(t *testing.T) {

	// make and configure a mocked events.TbAPI
	mockedTbAPI := &TbAPIMock{
		GetChatFunc: func(config tbapi.ChatInfoConfig) (tbapi.Chat, error) {
			panic("mock out the GetChat method")
		},
		GetUpdatesChanFunc: func(config tbapi.UpdateConfig) tbapi.UpdatesChannel {
			panic("mock out the GetUpdatesChan method")
		},
		RequestFunc: func(c tbapi.Chattable) (*tbapi.APIResponse, error) {
			panic("mock out the Request method")
		},
		SendFunc: func(c tbapi.Chattable) (tbapi.Message, error) {
			panic("mock out the Send method")
		},
	}

	// use mockedTbAPI in code that requires events.TbAPI
	// and then make assertions.

}

func (*TbAPIMock) GetChat

func (mock *TbAPIMock) GetChat(config tbapi.ChatInfoConfig) (tbapi.Chat, error)

GetChat calls GetChatFunc.

func (*TbAPIMock) GetChatCalls

func (mock *TbAPIMock) GetChatCalls() []struct {
	Config tbapi.ChatInfoConfig
}

GetChatCalls gets all the calls that were made to GetChat. Check the length with:

len(mockedTbAPI.GetChatCalls())

func (*TbAPIMock) GetUpdatesChan

func (mock *TbAPIMock) GetUpdatesChan(config tbapi.UpdateConfig) tbapi.UpdatesChannel

GetUpdatesChan calls GetUpdatesChanFunc.

func (*TbAPIMock) GetUpdatesChanCalls

func (mock *TbAPIMock) GetUpdatesChanCalls() []struct {
	Config tbapi.UpdateConfig
}

GetUpdatesChanCalls gets all the calls that were made to GetUpdatesChan. Check the length with:

len(mockedTbAPI.GetUpdatesChanCalls())

func (*TbAPIMock) Request

func (mock *TbAPIMock) Request(c tbapi.Chattable) (*tbapi.APIResponse, error)

Request calls RequestFunc.

func (*TbAPIMock) RequestCalls

func (mock *TbAPIMock) RequestCalls() []struct {
	C tbapi.Chattable
}

RequestCalls gets all the calls that were made to Request. Check the length with:

len(mockedTbAPI.RequestCalls())

func (*TbAPIMock) ResetCalls

func (mock *TbAPIMock) ResetCalls()

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

func (*TbAPIMock) ResetGetChatCalls

func (mock *TbAPIMock) ResetGetChatCalls()

ResetGetChatCalls reset all the calls that were made to GetChat.

func (*TbAPIMock) ResetGetUpdatesChanCalls

func (mock *TbAPIMock) ResetGetUpdatesChanCalls()

ResetGetUpdatesChanCalls reset all the calls that were made to GetUpdatesChan.

func (*TbAPIMock) ResetRequestCalls

func (mock *TbAPIMock) ResetRequestCalls()

ResetRequestCalls reset all the calls that were made to Request.

func (*TbAPIMock) ResetSendCalls

func (mock *TbAPIMock) ResetSendCalls()

ResetSendCalls reset all the calls that were made to Send.

func (*TbAPIMock) Send

func (mock *TbAPIMock) Send(c tbapi.Chattable) (tbapi.Message, error)

Send calls SendFunc.

func (*TbAPIMock) SendCalls

func (mock *TbAPIMock) SendCalls() []struct {
	C tbapi.Chattable
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedTbAPI.SendCalls())

Jump to

Keyboard shortcuts

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