refactor(discordbot): introduce Session interface for testability

Extract a Session interface from *discordgo.Session so DiscordBot methods
can be tested with a mock — no live Discord connection required. Add
AddHandler, RegisterCommands, and UserID methods to DiscordBot so
external callers (main.go, sys_channel_server.go) no longer reach
through bot.Session directly. Rewrite tests with a mockSession,
raising discordbot coverage from 12.5% to 66.7%.
This commit is contained in:
Houmgaor
2026-02-27 11:45:20 +01:00
parent 4e8c4b4e92
commit d38fef08bb
4 changed files with 315 additions and 373 deletions

View File

@@ -208,8 +208,8 @@ func (s *Server) Start() error {
// Start the discord bot for chat integration.
if s.erupeConfig.Discord.Enabled && s.discordBot != nil {
s.discordBot.Session.AddHandler(s.onDiscordMessage)
s.discordBot.Session.AddHandler(s.onInteraction)
s.discordBot.AddHandler(s.onDiscordMessage)
s.discordBot.AddHandler(s.onInteraction)
}
return nil