-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandmatcher_test.go
44 lines (37 loc) · 1.25 KB
/
commandmatcher_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
40
41
42
43
44
package commandmatcher
import (
"testing"
"github.com/pajbot/testhelper"
)
type test struct {
}
var (
command = &test{}
)
func TestNonMatchingCommand(t *testing.T) {
const testString = `!test lol`
m := New()
match, _ := m.Match(testString)
testhelper.AssertNil(t, match, "No command should be matched here")
}
func TestRegisterCommand(t *testing.T) {
const testString = `!test lol`
m := New()
cmd2 := m.Register([]string{"!test"}, command)
match, _ := m.Match(testString)
testhelper.AssertNotNil(t, match, "A command should be matched here")
testhelper.AssertInterfacesEqual(t, command, match, "A command should be matched here")
testhelper.AssertInterfacesEqual(t, command, cmd2, "A command should be matched here")
}
func TestDeregisterCommand(t *testing.T) {
const testString = `!test lol`
m := New()
cmd2 := m.Register([]string{"!test"}, command)
match, _ := m.Match(testString)
testhelper.AssertNotNil(t, match, "A command should be matched here")
testhelper.AssertInterfacesEqual(t, command, match, "A command should be matched here")
testhelper.AssertInterfacesEqual(t, command, cmd2, "A command should be matched here")
m.Deregister(cmd2)
match, _ = m.Match(testString)
testhelper.AssertNil(t, match, "No command should be matched here")
}