diff --git a/irc/conn_test.go b/irc/conn_test.go index 43f29297..c56a792a 100644 --- a/irc/conn_test.go +++ b/irc/conn_test.go @@ -128,7 +128,7 @@ func TestRecv(t *testing.T) { buf := &bytes.Buffer{} buf.WriteString("CMD\r\n") buf.WriteString("PING :test\r\n") - buf.WriteString("001\r\n") + buf.WriteString("001 foo\r\n") c.reader = bufio.NewReader(buf) c.ready.Add(1) diff --git a/server/irc_handler_test.go b/server/irc_handler_test.go index 9e0157a8..db01f428 100644 --- a/server/irc_handler_test.go +++ b/server/irc_handler_test.go @@ -35,13 +35,17 @@ func TestMain(m *testing.M) { } func dispatchMessage(msg *irc.Message) WSResponse { + return <-dispatchMessageMulti(msg) +} + +func dispatchMessageMulti(msg *irc.Message) chan WSResponse { c := irc.NewClient("nick", "user") c.Host = "host.com" s := NewSession(user) newIRCHandler(c, s).dispatchMessage(msg) - return <-s.broadcast + return s.broadcast } func checkResponse(t *testing.T, expectedType string, expectedData interface{}, res WSResponse) { @@ -161,17 +165,22 @@ func TestHandleIRCQuit(t *testing.T) { } func TestHandleIRCWelcome(t *testing.T) { - res := dispatchMessage(&irc.Message{ + res := dispatchMessageMulti(&irc.Message{ Command: irc.ReplyWelcome, Nick: "nick", - Params: []string{"target", "some", "text"}, + Params: []string{"nick", "some", "text"}, }) + checkResponse(t, "nick", Nick{ + Server: "host.com", + New: "nick", + }, <-res) + checkResponse(t, "pm", Chat{ Server: "host.com", From: "nick", Message: "some text", - }, res) + }, <-res) } func TestHandleIRCWhois(t *testing.T) {