42 lines
778 B
Go
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
|
|
}
|