mocks

package
v1.11.6 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 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 {
	// AddApprovedUserFunc mocks the AddApprovedUser method.
	AddApprovedUserFunc func(id int64, name string) error

	// IsApprovedUserFunc mocks the IsApprovedUser method.
	IsApprovedUserFunc func(userID int64) bool

	// OnMessageFunc mocks the OnMessage method.
	OnMessageFunc func(msg bot.Message) bot.Response

	// RemoveApprovedUserFunc mocks the RemoveApprovedUser method.
	RemoveApprovedUserFunc func(id int64) error

	// UpdateHamFunc mocks the UpdateHam method.
	UpdateHamFunc func(msg string) error

	// UpdateSpamFunc mocks the UpdateSpam method.
	UpdateSpamFunc func(msg string) error
	// 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{
		AddApprovedUserFunc: func(id int64, name string) error {
			panic("mock out the AddApprovedUser method")
		},
		IsApprovedUserFunc: func(userID int64) bool {
			panic("mock out the IsApprovedUser method")
		},
		OnMessageFunc: func(msg bot.Message) bot.Response {
			panic("mock out the OnMessage method")
		},
		RemoveApprovedUserFunc: func(id int64) error {
			panic("mock out the RemoveApprovedUser method")
		},
		UpdateHamFunc: func(msg string) error {
			panic("mock out the UpdateHam method")
		},
		UpdateSpamFunc: func(msg string) error {
			panic("mock out the UpdateSpam method")
		},
	}

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

}

func (*BotMock) AddApprovedUser added in v1.6.0

func (mock *BotMock) AddApprovedUser(id int64, name string) error

AddApprovedUser calls AddApprovedUserFunc.

func (*BotMock) AddApprovedUserCalls added in v1.6.0

func (mock *BotMock) AddApprovedUserCalls() []struct {
	ID   int64
	Name string
}

AddApprovedUserCalls gets all the calls that were made to AddApprovedUser. Check the length with:

len(mockedBot.AddApprovedUserCalls())

func (*BotMock) IsApprovedUser added in v1.6.0

func (mock *BotMock) IsApprovedUser(userID int64) bool

IsApprovedUser calls IsApprovedUserFunc.

func (*BotMock) IsApprovedUserCalls added in v1.6.0

func (mock *BotMock) IsApprovedUserCalls() []struct {
	UserID int64
}

IsApprovedUserCalls gets all the calls that were made to IsApprovedUser. Check the length with:

len(mockedBot.IsApprovedUserCalls())

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) RemoveApprovedUser added in v1.6.0

func (mock *BotMock) RemoveApprovedUser(id int64) error

RemoveApprovedUser calls RemoveApprovedUserFunc.

func (*BotMock) RemoveApprovedUserCalls added in v1.6.0

func (mock *BotMock) RemoveApprovedUserCalls() []struct {
	ID int64
}

RemoveApprovedUserCalls gets all the calls that were made to RemoveApprovedUser. Check the length with:

len(mockedBot.RemoveApprovedUserCalls())

func (*BotMock) ResetAddApprovedUserCalls added in v1.6.0

func (mock *BotMock) ResetAddApprovedUserCalls()

ResetAddApprovedUserCalls reset all the calls that were made to AddApprovedUser.

func (*BotMock) ResetCalls

func (mock *BotMock) ResetCalls()

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

func (*BotMock) ResetIsApprovedUserCalls added in v1.6.0

func (mock *BotMock) ResetIsApprovedUserCalls()

ResetIsApprovedUserCalls reset all the calls that were made to IsApprovedUser.

func (*BotMock) ResetOnMessageCalls

func (mock *BotMock) ResetOnMessageCalls()

ResetOnMessageCalls reset all the calls that were made to OnMessage.

func (*BotMock) ResetRemoveApprovedUserCalls added in v1.6.0

func (mock *BotMock) ResetRemoveApprovedUserCalls()

ResetRemoveApprovedUserCalls reset all the calls that were made to RemoveApprovedUser.

func (*BotMock) ResetUpdateHamCalls added in v0.2.0

func (mock *BotMock) ResetUpdateHamCalls()

ResetUpdateHamCalls reset all the calls that were made to UpdateHam.

func (*BotMock) ResetUpdateSpamCalls added in v0.2.0

func (mock *BotMock) ResetUpdateSpamCalls()

ResetUpdateSpamCalls reset all the calls that were made to UpdateSpam.

func (*BotMock) UpdateHam added in v0.2.0

func (mock *BotMock) UpdateHam(msg string) error

UpdateHam calls UpdateHamFunc.

func (*BotMock) UpdateHamCalls added in v0.2.0

func (mock *BotMock) UpdateHamCalls() []struct {
	Msg string
}

UpdateHamCalls gets all the calls that were made to UpdateHam. Check the length with:

len(mockedBot.UpdateHamCalls())

func (*BotMock) UpdateSpam added in v0.2.0

func (mock *BotMock) UpdateSpam(msg string) error

UpdateSpam calls UpdateSpamFunc.

func (*BotMock) UpdateSpamCalls added in v0.2.0

func (mock *BotMock) UpdateSpamCalls() []struct {
	Msg string
}

UpdateSpamCalls gets all the calls that were made to UpdateSpam. Check the length with:

len(mockedBot.UpdateSpamCalls())

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 TbAPIMock

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

	// GetChatAdministratorsFunc mocks the GetChatAdministrators method.
	GetChatAdministratorsFunc func(config tbapi.ChatAdministratorsConfig) ([]tbapi.ChatMember, 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")
		},
		GetChatAdministratorsFunc: func(config tbapi.ChatAdministratorsConfig) ([]tbapi.ChatMember, error) {
			panic("mock out the GetChatAdministrators 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) GetChatAdministrators added in v1.1.0

func (mock *TbAPIMock) GetChatAdministrators(config tbapi.ChatAdministratorsConfig) ([]tbapi.ChatMember, error)

GetChatAdministrators calls GetChatAdministratorsFunc.

func (*TbAPIMock) GetChatAdministratorsCalls added in v1.1.0

func (mock *TbAPIMock) GetChatAdministratorsCalls() []struct {
	Config tbapi.ChatAdministratorsConfig
}

GetChatAdministratorsCalls gets all the calls that were made to GetChatAdministrators. Check the length with:

len(mockedTbAPI.GetChatAdministratorsCalls())

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) ResetGetChatAdministratorsCalls added in v1.1.0

func (mock *TbAPIMock) ResetGetChatAdministratorsCalls()

ResetGetChatAdministratorsCalls reset all the calls that were made to GetChatAdministrators.

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