The test setup is incorrect - the CreateSession mock is directly panicking with the message "GuildMemberNickname called" rather than returning a mock session that would panic when its GuildMemberNickname method is called. This creates misleading test behavior since the panic happens at session creation time rather than when the nickname method is invoked. Consider refactoring to:
CreateSession = func() (DiscordSessionWrapper, error) {
return &mockDiscordSession{
GuildMemberNicknameFunc: func(guildID, userID, nickname string, options ...discordgo.RequestOption) error {
panic("GuildMemberNickname called")
},
}, nil
}
This would properly test that the method is being called while maintaining the expected panic behavior.
CreateSession = func() (DiscordSessionWrapper, error) {
return &mockDiscordSession{
GuildMemberNicknameFunc: func(guildID, userID, nickname string, options ...discordgo.RequestOption) error {
panic("GuildMemberNickname called")
},
}, nil
}
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Originally posted by @graphite-app[bot] in #114 (comment)