Documentation ¶
Index ¶
- type APIMock
- func (mock *APIMock) Announce(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) AnnounceCalls() []struct{ ... }
- func (mock *APIMock) AuthCodeURL(state string, scopes []string) string
- func (mock *APIMock) AuthCodeURLCalls() []struct{ ... }
- func (mock *APIMock) Ban(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) BanCalls() []struct{ ... }
- func (mock *APIMock) ClearChat(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token) (*oauth2.Token, error)
- func (mock *APIMock) ClearChatCalls() []struct{ ... }
- func (mock *APIMock) DeleteChatMessage(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) DeleteChatMessageCalls() []struct{ ... }
- func (mock *APIMock) Exchange(ctx context.Context, code string) (*oauth2.Token, error)
- func (mock *APIMock) ExchangeCalls() []struct{ ... }
- func (mock *APIMock) GetChannelByID(ctx context.Context, id int64) (*twitch.Channel, error)
- func (mock *APIMock) GetChannelByIDCalls() []struct{ ... }
- func (mock *APIMock) GetChannelModerators(ctx context.Context, id int64, userToken *oauth2.Token) ([]*twitch.ChannelModerator, *oauth2.Token, error)
- func (mock *APIMock) GetChannelModeratorsCalls() []struct{ ... }
- func (mock *APIMock) GetGameByID(ctx context.Context, id int64) (*twitch.Category, error)
- func (mock *APIMock) GetGameByIDCalls() []struct{ ... }
- func (mock *APIMock) GetGameByName(ctx context.Context, name string) (*twitch.Category, error)
- func (mock *APIMock) GetGameByNameCalls() []struct{ ... }
- func (mock *APIMock) GetGameLinks(ctx context.Context, twitchCategory int64) ([]twitch.GameLink, error)
- func (mock *APIMock) GetGameLinksCalls() []struct{ ... }
- func (mock *APIMock) GetModeratedChannels(ctx context.Context, modID int64, modToken *oauth2.Token) ([]*twitch.ModeratedChannel, *oauth2.Token, error)
- func (mock *APIMock) GetModeratedChannelsCalls() []struct{ ... }
- func (mock *APIMock) GetStreamByUserID(ctx context.Context, id int64) (*twitch.Stream, error)
- func (mock *APIMock) GetStreamByUserIDCalls() []struct{ ... }
- func (mock *APIMock) GetStreamByUsername(ctx context.Context, username string) (*twitch.Stream, error)
- func (mock *APIMock) GetStreamByUsernameCalls() []struct{ ... }
- func (mock *APIMock) GetUserByID(ctx context.Context, id int64) (*twitch.User, error)
- func (mock *APIMock) GetUserByIDCalls() []struct{ ... }
- func (mock *APIMock) GetUserByToken(ctx context.Context, userToken *oauth2.Token) (*twitch.User, *oauth2.Token, error)
- func (mock *APIMock) GetUserByTokenCalls() []struct{ ... }
- func (mock *APIMock) GetUserByUsername(ctx context.Context, username string) (*twitch.User, error)
- func (mock *APIMock) GetUserByUsernameCalls() []struct{ ... }
- func (mock *APIMock) ModifyChannel(ctx context.Context, broadcasterID int64, userToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) ModifyChannelCalls() []struct{ ... }
- func (mock *APIMock) SearchCategories(ctx context.Context, query string) ([]*twitch.Category, error)
- func (mock *APIMock) SearchCategoriesCalls() []struct{ ... }
- func (mock *APIMock) SetChatColor(ctx context.Context, userID int64, userToken *oauth2.Token, color string) (*oauth2.Token, error)
- func (mock *APIMock) SetChatColorCalls() []struct{ ... }
- func (mock *APIMock) Unban(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) UnbanCalls() []struct{ ... }
- func (mock *APIMock) UpdateChatSettings(ctx context.Context, broadcasterID int64, modID int64, modToken *oauth2.Token, ...) (*oauth2.Token, error)
- func (mock *APIMock) UpdateChatSettingsCalls() []struct{ ... }
- func (mock *APIMock) Validate(ctx context.Context, tok *oauth2.Token) (*twitch.Validation, *oauth2.Token, error)
- func (mock *APIMock) ValidateCalls() []struct{ ... }
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 ¶
AuthCodeURL calls AuthCodeURLFunc.
func (*APIMock) AuthCodeURLCalls ¶
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) ExchangeCalls ¶
ExchangeCalls gets all the calls that were made to Exchange. Check the length with:
len(mockedAPI.ExchangeCalls())
func (*APIMock) GetChannelByID ¶
GetChannelByID calls GetChannelByIDFunc.
func (*APIMock) GetChannelByIDCalls ¶
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 ¶
GetGameByID calls GetGameByIDFunc.
func (*APIMock) GetGameByIDCalls ¶
GetGameByIDCalls gets all the calls that were made to GetGameByID. Check the length with:
len(mockedAPI.GetGameByIDCalls())
func (*APIMock) GetGameByName ¶
GetGameByName calls GetGameByNameFunc.
func (*APIMock) GetGameByNameCalls ¶
GetGameByNameCalls gets all the calls that were made to GetGameByName. Check the length with:
len(mockedAPI.GetGameByNameCalls())
func (*APIMock) GetGameLinks ¶
func (mock *APIMock) GetGameLinks(ctx context.Context, twitchCategory int64) ([]twitch.GameLink, error)
GetGameLinks calls GetGameLinksFunc.
func (*APIMock) GetGameLinksCalls ¶
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 ¶
GetStreamByUserID calls GetStreamByUserIDFunc.
func (*APIMock) GetStreamByUserIDCalls ¶
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 ¶
GetStreamByUsernameCalls gets all the calls that were made to GetStreamByUsername. Check the length with:
len(mockedAPI.GetStreamByUsernameCalls())
func (*APIMock) GetUserByID ¶
GetUserByID calls GetUserByIDFunc.
func (*APIMock) GetUserByIDCalls ¶
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 ¶
GetUserByTokenCalls gets all the calls that were made to GetUserByToken. Check the length with:
len(mockedAPI.GetUserByTokenCalls())
func (*APIMock) GetUserByUsername ¶
GetUserByUsername calls GetUserByUsernameFunc.
func (*APIMock) GetUserByUsernameCalls ¶
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 ¶
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())