-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_test.go
44 lines (40 loc) · 989 Bytes
/
message_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 sirius
import (
"github.com/kayex/sirius/slack"
"github.com/kayex/sirius/text"
"testing"
)
func TestMessage_Query(t *testing.T) {
cases := []struct {
msg Message
q text.Query
exp bool
}{
{
msg: NewMessage(slack.UserID{"123", "abc"}, "Alligators eat mattresses", "#channel", "0"),
q: text.Word("Alligators"),
exp: true,
},
{
msg: NewMessage(slack.UserID{"123", "abc"}, "Alligators eat mattresses", "#channel", "0"),
q: text.Word("mattresses"),
exp: true,
},
{
msg: NewMessage(slack.UserID{"123", "abc"}, "Alligators eat mattresses", "#channel", "0"),
q: text.Word("gators"),
exp: false,
},
{
msg: NewMessage(slack.UserID{"123", "abc"}, "Alligators eat meat", "#channel", "0"),
q: text.Word("eat"),
exp: true,
},
}
for _, c := range cases {
act := c.msg.Query(c.q)
if act != c.exp {
t.Errorf("Expected Message.Query(%#v) for message %q to return %v, got %v", c.q, c.msg.Text, c.exp, act)
}
}
}