mlp-server-tools/draftbot/draftbot_test.go

43 lines
778 B
Go
Raw Normal View History

2019-06-28 09:03:42 +00:00
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
}