Add some tests to the IRC client
This commit is contained in:
parent
ff9cae7794
commit
da8915328d
15 changed files with 3088 additions and 39 deletions
43
irc/message_test.go
Normal file
43
irc/message_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package irc
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseMessage(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
expected *Message
|
||||
}{
|
||||
{
|
||||
":user CMD #chan :some message\r\n",
|
||||
&Message{
|
||||
Prefix: "user",
|
||||
Nick: "user",
|
||||
Command: "CMD",
|
||||
Params: []string{"#chan", "some message"},
|
||||
Trailing: "some message",
|
||||
},
|
||||
}, {
|
||||
":nick!user@host.com CMD a b\r\n",
|
||||
&Message{
|
||||
Prefix: "nick!user@host.com",
|
||||
Nick: "nick",
|
||||
Command: "CMD",
|
||||
Params: []string{"a", "b"},
|
||||
},
|
||||
}, {
|
||||
"CMD a b :\r\n",
|
||||
&Message{
|
||||
Command: "CMD",
|
||||
Params: []string{"a", "b"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
assert.Equal(t, tc.expected, parseMessage(tc.input))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue