mlp-server-tools/draftbot/draftbot_test.go
Hamcha 9b5ad472c7
All checks were successful
continuous-integration/drone/push Build is passing
Refactor messages handling
2019-06-28 11:03:42 +02:00

42 lines
778 B
Go

package main_test
import (
"testing"
"git.fromouter.space/mcg/cardgage/client/bot"
room "git.fromouter.space/mcg/cardgage/room/api"
draft "git.fromouter.space/mcg/mlp-server-tools/draftbot"
)
type MockServer struct {
in chan room.ServerMessage
out chan room.BotMessage
}
func makeMockServer() *MockServer {
in := make(chan room.ServerMessage)
out := make(chan room.BotMessage)
srv := &MockServer{
in: in,
out: out,
}
return srv
}
func (m *MockServer) Send(msg room.BotMessage) {
m.out <- msg
}
func (m *MockServer) Bind(fn bot.MessageHandler) {
for msg := range m.in {
fn(msg)
}
}
func TestDraftSession(t *testing.T) {
mock := makeMockServer()
draftbot := draft.NewDraftBot(mock, "bot")
go mock.Bind(draftbot.OnMessage)
//TODO sample session
}