forked from ildus/jabber_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
39 lines (32 loc) · 943 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCommandParse(t *testing.T) {
var err error
text := "/connect [email protected] pass host.com 50"
command, _ := parseCommand(text)
assert.Equal(t, command.Cmd, CMD_CONNECT)
assert.Equal(t, command.Jid, "[email protected]")
assert.Equal(t, command.Password, "pass")
assert.Equal(t, command.Port, uint16(50))
text = "/disconnect"
command, _ = parseCommand(text)
assert.Equal(t, command.Cmd, CMD_DISCONNECT)
text = "/check"
command, _ = parseCommand(text)
assert.Equal(t, command.Cmd, CMD_CHECK)
text = "/conn asdf asdf"
command, err = parseCommand(text)
assert.Nil(t, command)
assert.NotNil(t, err)
text = "/connect [email protected]"
command, err = parseCommand(text)
assert.Nil(t, command)
assert.NotNil(t, err)
text = "/connect [email protected] pass"
command, err = parseCommand(text)
assert.NotNil(t, command)
assert.Nil(t, err)
}