twitchmocks

package
v0.0.0-...-fb49ba0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMock

type APIMock struct {
	// AnnounceFunc mocks the Announce method.
	AnnounceFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, message string, color string) (*oauth2.Token, error)

	// AuthCodeURLFunc mocks the AuthCodeURL method.
	AuthCodeURLFunc func(state string, scopes []string) string

	// BanFunc mocks the Ban method.
	BanFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, req *twitch.BanRequest) (*oauth2.Token, error)

	// ClearChatFunc mocks the ClearChat method.
	ClearChatFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token) (*oauth2.Token, error)

	// DeleteChatMessageFunc mocks the DeleteChatMessage method.
	DeleteChatMessageFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, id string) (*oauth2.Token, error)

	// ExchangeFunc mocks the Exchange method.
	ExchangeFunc func(ctx context.Context, code string) (*oauth2.Token, error)

	// GetChannelByIDFunc mocks the GetChannelByID method.
	GetChannelByIDFunc func(ctx context.Context, id int64) (*twitch.Channel, error)

	// GetChannelModeratorsFunc mocks the GetChannelModerators method.
	GetChannelModeratorsFunc func(ctx context.Context, id int64, userToken *oauth2.Token) ([]*twitch.ChannelModerator, *oauth2.Token, error)

	// GetGameByIDFunc mocks the GetGameByID method.
	GetGameByIDFunc func(ctx context.Context, id int64) (*twitch.Category, error)

	// GetGameByNameFunc mocks the GetGameByName method.
	GetGameByNameFunc func(ctx context.Context, name string) (*twitch.Category, error)

	// GetGameLinksFunc mocks the GetGameLinks method.
	GetGameLinksFunc func(ctx context.Context, twitchCategory int64) ([]twitch.GameLink, error)

	// GetModeratedChannelsFunc mocks the GetModeratedChannels method.
	GetModeratedChannelsFunc func(ctx context.Context, modID int64, modToken *oauth2.Token) ([]*twitch.ModeratedChannel, *oauth2.Token, error)

	// GetStreamByUserIDFunc mocks the GetStreamByUserID method.
	GetStreamByUserIDFunc func(ctx context.Context, id int64) (*twitch.Stream, error)

	// GetStreamByUsernameFunc mocks the GetStreamByUsername method.
	GetStreamByUsernameFunc func(ctx context.Context, username string) (*twitch.Stream, error)

	// GetUserByIDFunc mocks the GetUserByID method.
	GetUserByIDFunc func(ctx context.Context, id int64) (*twitch.User, error)

	// GetUserByTokenFunc mocks the GetUserByToken method.
	GetUserByTokenFunc func(ctx context.Context, userToken *oauth2.Token) (*twitch.User, *oauth2.Token, error)

	// GetUserByUsernameFunc mocks the GetUserByUsername method.
	GetUserByUsernameFunc func(ctx context.Context, username string) (*twitch.User, error)

	// ModifyChannelFunc mocks the ModifyChannel method.
	ModifyChannelFunc func(ctx context.Context, broadcasterID int64, userToken *oauth2.Token, title *string, gameID *int64) (*oauth2.Token, error)

	// SearchCategoriesFunc mocks the SearchCategories method.
	SearchCategoriesFunc func(ctx context.Context, query string) ([]*twitch.Category, error)

	// SetChatColorFunc mocks the SetChatColor method.
	SetChatColorFunc func(ctx context.Context, userID int64, userToken *oauth2.Token, color string) (*oauth2.Token, error)

	// UnbanFunc mocks the Unban method.
	UnbanFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, userID int64) (*oauth2.Token, error)

	// UpdateChatSettingsFunc mocks the UpdateChatSettings method.
	UpdateChatSettingsFunc func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, patch *twitch.ChatSettingsPatch) (*oauth2.Token, error)

	// ValidateFunc mocks the Validate method.
	ValidateFunc func(ctx context.Context, tok *oauth2.Token) (*twitch.Validation, *oauth2.Token, error)
	// contains filtered or unexported fields
}

APIMock is a mock implementation of twitch.API.

func TestSomethingThatUsesAPI(t *testing.T) {

	// make and configure a mocked twitch.API
	mockedAPI := &APIMock{
		AnnounceFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, message string, color string) (*oauth2.Token, error) {
			panic("mock out the Announce method")
		},
		AuthCodeURLFunc: func(state string, scopes []string) string {
			panic("mock out the AuthCodeURL method")
		},
		BanFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, req *twitch.BanRequest) (*oauth2.Token, error) {
			panic("mock out the Ban method")
		},
		ClearChatFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token) (*oauth2.Token, error) {
			panic("mock out the ClearChat method")
		},
		DeleteChatMessageFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, id string) (*oauth2.Token, error) {
			panic("mock out the DeleteChatMessage method")
		},
		ExchangeFunc: func(ctx context.Context, code string) (*oauth2.Token, error) {
			panic("mock out the Exchange method")
		},
		GetChannelByIDFunc: func(ctx context.Context, id int64) (*twitch.Channel, error) {
			panic("mock out the GetChannelByID method")
		},
		GetChannelModeratorsFunc: func(ctx context.Context, id int64, userToken *oauth2.Token) ([]*twitch.ChannelModerator, *oauth2.Token, error) {
			panic("mock out the GetChannelModerators method")
		},
		GetGameByIDFunc: func(ctx context.Context, id int64) (*twitch.Category, error) {
			panic("mock out the GetGameByID method")
		},
		GetGameByNameFunc: func(ctx context.Context, name string) (*twitch.Category, error) {
			panic("mock out the GetGameByName method")
		},
		GetGameLinksFunc: func(ctx context.Context, twitchCategory int64) ([]twitch.GameLink, error) {
			panic("mock out the GetGameLinks method")
		},
		GetModeratedChannelsFunc: func(ctx context.Context, modID int64, modToken *oauth2.Token) ([]*twitch.ModeratedChannel, *oauth2.Token, error) {
			panic("mock out the GetModeratedChannels method")
		},
		GetStreamByUserIDFunc: func(ctx context.Context, id int64) (*twitch.Stream, error) {
			panic("mock out the GetStreamByUserID method")
		},
		GetStreamByUsernameFunc: func(ctx context.Context, username string) (*twitch.Stream, error) {
			panic("mock out the GetStreamByUsername method")
		},
		GetUserByIDFunc: func(ctx context.Context, id int64) (*twitch.User, error) {
			panic("mock out the GetUserByID method")
		},
		GetUserByTokenFunc: func(ctx context.Context, userToken *oauth2.Token) (*twitch.User, *oauth2.Token, error) {
			panic("mock out the GetUserByToken method")
		},
		GetUserByUsernameFunc: func(ctx context.Context, username string) (*twitch.User, error) {
			panic("mock out the GetUserByUsername method")
		},
		ModifyChannelFunc: func(ctx context.Context, broadcasterID int64, userToken *oauth2.Token, title *string, gameID *int64) (*oauth2.Token, error) {
			panic("mock out the ModifyChannel method")
		},
		SearchCategoriesFunc: func(ctx context.Context, query string) ([]*twitch.Category, error) {
			panic("mock out the SearchCategories method")
		},
		SetChatColorFunc: func(ctx context.Context, userID int64, userToken *oauth2.Token, color string) (*oauth2.Token, error) {
			panic("mock out the SetChatColor method")
		},
		UnbanFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, userID int64) (*oauth2.Token, error) {
			panic("mock out the Unban method")
		},
		UpdateChatSettingsFunc: func(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, patch *twitch.ChatSettingsPatch) (*oauth2.Token, error) {
			panic("mock out the UpdateChatSettings method")
		},
		ValidateFunc: func(ctx context.Context, tok *oauth2.Token) (*twitch.Validation, *oauth2.Token, error) {
			panic("mock out the Validate method")
		},
	}

	// use mockedAPI in code that requires twitch.API
	// and then make assertions.

}

func (*APIMock) Announce

func (mock *APIMock) Announce(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, message string, color string) (*oauth2.Token, error)

Announce calls AnnounceFunc.

func (*APIMock) AnnounceCalls

func (mock *APIMock) AnnounceCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
	Message       string
	Color         string
}

AnnounceCalls gets all the calls that were made to Announce. Check the length with:

len(mockedAPI.AnnounceCalls())

func (*APIMock) AuthCodeURL

func (mock *APIMock) AuthCodeURL(state string, scopes []string) string

AuthCodeURL calls AuthCodeURLFunc.

func (*APIMock) AuthCodeURLCalls

func (mock *APIMock) AuthCodeURLCalls() []struct {
	State  string
	Scopes []string
}

AuthCodeURLCalls gets all the calls that were made to AuthCodeURL. Check the length with:

len(mockedAPI.AuthCodeURLCalls())

func (*APIMock) Ban

func (mock *APIMock) Ban(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, req *twitch.BanRequest) (*oauth2.Token, error)

Ban calls BanFunc.

func (*APIMock) BanCalls

func (mock *APIMock) BanCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
	Req           *twitch.BanRequest
}

BanCalls gets all the calls that were made to Ban. Check the length with:

len(mockedAPI.BanCalls())

func (*APIMock) ClearChat

func (mock *APIMock) ClearChat(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token) (*oauth2.Token, error)

ClearChat calls ClearChatFunc.

func (*APIMock) ClearChatCalls

func (mock *APIMock) ClearChatCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
}

ClearChatCalls gets all the calls that were made to ClearChat. Check the length with:

len(mockedAPI.ClearChatCalls())

func (*APIMock) DeleteChatMessage

func (mock *APIMock) DeleteChatMessage(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, id string) (*oauth2.Token, error)

DeleteChatMessage calls DeleteChatMessageFunc.

func (*APIMock) DeleteChatMessageCalls

func (mock *APIMock) DeleteChatMessageCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
	ID            string
}

DeleteChatMessageCalls gets all the calls that were made to DeleteChatMessage. Check the length with:

len(mockedAPI.DeleteChatMessageCalls())

func (*APIMock) Exchange

func (mock *APIMock) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

Exchange calls ExchangeFunc.

func (*APIMock) ExchangeCalls

func (mock *APIMock) ExchangeCalls() []struct {
	Ctx  context.Context
	Code string
}

ExchangeCalls gets all the calls that were made to Exchange. Check the length with:

len(mockedAPI.ExchangeCalls())

func (*APIMock) GetChannelByID

func (mock *APIMock) GetChannelByID(ctx context.Context, id int64) (*twitch.Channel, error)

GetChannelByID calls GetChannelByIDFunc.

func (*APIMock) GetChannelByIDCalls

func (mock *APIMock) GetChannelByIDCalls() []struct {
	Ctx context.Context
	ID  int64
}

GetChannelByIDCalls gets all the calls that were made to GetChannelByID. Check the length with:

len(mockedAPI.GetChannelByIDCalls())

func (*APIMock) GetChannelModerators

func (mock *APIMock) GetChannelModerators(ctx context.Context, id int64, userToken *oauth2.Token) ([]*twitch.ChannelModerator, *oauth2.Token, error)

GetChannelModerators calls GetChannelModeratorsFunc.

func (*APIMock) GetChannelModeratorsCalls

func (mock *APIMock) GetChannelModeratorsCalls() []struct {
	Ctx       context.Context
	ID        int64
	UserToken *oauth2.Token
}

GetChannelModeratorsCalls gets all the calls that were made to GetChannelModerators. Check the length with:

len(mockedAPI.GetChannelModeratorsCalls())

func (*APIMock) GetGameByID

func (mock *APIMock) GetGameByID(ctx context.Context, id int64) (*twitch.Category, error)

GetGameByID calls GetGameByIDFunc.

func (*APIMock) GetGameByIDCalls

func (mock *APIMock) GetGameByIDCalls() []struct {
	Ctx context.Context
	ID  int64
}

GetGameByIDCalls gets all the calls that were made to GetGameByID. Check the length with:

len(mockedAPI.GetGameByIDCalls())

func (*APIMock) GetGameByName

func (mock *APIMock) GetGameByName(ctx context.Context, name string) (*twitch.Category, error)

GetGameByName calls GetGameByNameFunc.

func (*APIMock) GetGameByNameCalls

func (mock *APIMock) GetGameByNameCalls() []struct {
	Ctx  context.Context
	Name string
}

GetGameByNameCalls gets all the calls that were made to GetGameByName. Check the length with:

len(mockedAPI.GetGameByNameCalls())
func (mock *APIMock) GetGameLinks(ctx context.Context, twitchCategory int64) ([]twitch.GameLink, error)

GetGameLinks calls GetGameLinksFunc.

func (*APIMock) GetGameLinksCalls

func (mock *APIMock) GetGameLinksCalls() []struct {
	Ctx            context.Context
	TwitchCategory int64
}

GetGameLinksCalls gets all the calls that were made to GetGameLinks. Check the length with:

len(mockedAPI.GetGameLinksCalls())

func (*APIMock) GetModeratedChannels

func (mock *APIMock) GetModeratedChannels(ctx context.Context, modID int64, modToken *oauth2.Token) ([]*twitch.ModeratedChannel, *oauth2.Token, error)

GetModeratedChannels calls GetModeratedChannelsFunc.

func (*APIMock) GetModeratedChannelsCalls

func (mock *APIMock) GetModeratedChannelsCalls() []struct {
	Ctx      context.Context
	ModID    int64
	ModToken *oauth2.Token
}

GetModeratedChannelsCalls gets all the calls that were made to GetModeratedChannels. Check the length with:

len(mockedAPI.GetModeratedChannelsCalls())

func (*APIMock) GetStreamByUserID

func (mock *APIMock) GetStreamByUserID(ctx context.Context, id int64) (*twitch.Stream, error)

GetStreamByUserID calls GetStreamByUserIDFunc.

func (*APIMock) GetStreamByUserIDCalls

func (mock *APIMock) GetStreamByUserIDCalls() []struct {
	Ctx context.Context
	ID  int64
}

GetStreamByUserIDCalls gets all the calls that were made to GetStreamByUserID. Check the length with:

len(mockedAPI.GetStreamByUserIDCalls())

func (*APIMock) GetStreamByUsername

func (mock *APIMock) GetStreamByUsername(ctx context.Context, username string) (*twitch.Stream, error)

GetStreamByUsername calls GetStreamByUsernameFunc.

func (*APIMock) GetStreamByUsernameCalls

func (mock *APIMock) GetStreamByUsernameCalls() []struct {
	Ctx      context.Context
	Username string
}

GetStreamByUsernameCalls gets all the calls that were made to GetStreamByUsername. Check the length with:

len(mockedAPI.GetStreamByUsernameCalls())

func (*APIMock) GetUserByID

func (mock *APIMock) GetUserByID(ctx context.Context, id int64) (*twitch.User, error)

GetUserByID calls GetUserByIDFunc.

func (*APIMock) GetUserByIDCalls

func (mock *APIMock) GetUserByIDCalls() []struct {
	Ctx context.Context
	ID  int64
}

GetUserByIDCalls gets all the calls that were made to GetUserByID. Check the length with:

len(mockedAPI.GetUserByIDCalls())

func (*APIMock) GetUserByToken

func (mock *APIMock) GetUserByToken(ctx context.Context, userToken *oauth2.Token) (*twitch.User, *oauth2.Token, error)

GetUserByToken calls GetUserByTokenFunc.

func (*APIMock) GetUserByTokenCalls

func (mock *APIMock) GetUserByTokenCalls() []struct {
	Ctx       context.Context
	UserToken *oauth2.Token
}

GetUserByTokenCalls gets all the calls that were made to GetUserByToken. Check the length with:

len(mockedAPI.GetUserByTokenCalls())

func (*APIMock) GetUserByUsername

func (mock *APIMock) GetUserByUsername(ctx context.Context, username string) (*twitch.User, error)

GetUserByUsername calls GetUserByUsernameFunc.

func (*APIMock) GetUserByUsernameCalls

func (mock *APIMock) GetUserByUsernameCalls() []struct {
	Ctx      context.Context
	Username string
}

GetUserByUsernameCalls gets all the calls that were made to GetUserByUsername. Check the length with:

len(mockedAPI.GetUserByUsernameCalls())

func (*APIMock) ModifyChannel

func (mock *APIMock) ModifyChannel(ctx context.Context, broadcasterID int64, userToken *oauth2.Token, title *string, gameID *int64) (*oauth2.Token, error)

ModifyChannel calls ModifyChannelFunc.

func (*APIMock) ModifyChannelCalls

func (mock *APIMock) ModifyChannelCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	UserToken     *oauth2.Token
	Title         *string
	GameID        *int64
}

ModifyChannelCalls gets all the calls that were made to ModifyChannel. Check the length with:

len(mockedAPI.ModifyChannelCalls())

func (*APIMock) SearchCategories

func (mock *APIMock) SearchCategories(ctx context.Context, query string) ([]*twitch.Category, error)

SearchCategories calls SearchCategoriesFunc.

func (*APIMock) SearchCategoriesCalls

func (mock *APIMock) SearchCategoriesCalls() []struct {
	Ctx   context.Context
	Query string
}

SearchCategoriesCalls gets all the calls that were made to SearchCategories. Check the length with:

len(mockedAPI.SearchCategoriesCalls())

func (*APIMock) SetChatColor

func (mock *APIMock) SetChatColor(ctx context.Context, userID int64, userToken *oauth2.Token, color string) (*oauth2.Token, error)

SetChatColor calls SetChatColorFunc.

func (*APIMock) SetChatColorCalls

func (mock *APIMock) SetChatColorCalls() []struct {
	Ctx       context.Context
	UserID    int64
	UserToken *oauth2.Token
	Color     string
}

SetChatColorCalls gets all the calls that were made to SetChatColor. Check the length with:

len(mockedAPI.SetChatColorCalls())

func (*APIMock) Unban

func (mock *APIMock) Unban(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, userID int64) (*oauth2.Token, error)

Unban calls UnbanFunc.

func (*APIMock) UnbanCalls

func (mock *APIMock) UnbanCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
	UserID        int64
}

UnbanCalls gets all the calls that were made to Unban. Check the length with:

len(mockedAPI.UnbanCalls())

func (*APIMock) UpdateChatSettings

func (mock *APIMock) UpdateChatSettings(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, patch *twitch.ChatSettingsPatch) (*oauth2.Token, error)

UpdateChatSettings calls UpdateChatSettingsFunc.

func (*APIMock) UpdateChatSettingsCalls

func (mock *APIMock) UpdateChatSettingsCalls() []struct {
	Ctx           context.Context
	BroadcasterID int64
	ModID         int64
	ModToken      *oauth2.Token
	Patch         *twitch.ChatSettingsPatch
}

UpdateChatSettingsCalls gets all the calls that were made to UpdateChatSettings. Check the length with:

len(mockedAPI.UpdateChatSettingsCalls())

func (*APIMock) Validate

func (mock *APIMock) Validate(ctx context.Context, tok *oauth2.Token) (*twitch.Validation, *oauth2.Token, error)

Validate calls ValidateFunc.

func (*APIMock) ValidateCalls

func (mock *APIMock) ValidateCalls() []struct {
	Ctx context.Context
	Tok *oauth2.Token
}

ValidateCalls gets all the calls that were made to Validate. Check the length with:

len(mockedAPI.ValidateCalls())

Jump to

Keyboard shortcuts

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