forked from Difrex/go-idec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages_test.go
56 lines (51 loc) · 1.05 KB
/
messages_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
45
46
47
48
49
50
51
52
53
54
55
56
package idec
import (
"testing"
)
func TestCollectTags(t *testing.T) {
tags := Tags{
II: "ok",
Repto: "hXzRNEzmMuzKkT1HCxUb",
}
collected, err := tags.CollectTags()
if err != nil {
t.Error(err)
}
// With repto
if collected != "ii/ok/repto/hXzRNEzmMuzKkT1HCxUb" {
t.Error("Wrong tags collection")
}
// Without repto
tags.Repto = ""
collected, err = tags.CollectTags()
if collected != "ii/ok" {
t.Error("Wrong tags collection")
}
// Wrong ii/ok
tags.II = ""
_, err = tags.CollectTags()
if err == nil {
t.Error("Wrong tags collection")
}
}
func TestPrepareMessageForSend(t *testing.T) {
p := &PointMessage{
Echo: "ii.test.14",
To: "All",
Subg: "Test message",
Body: "This is a message body.",
}
result := p.PrepareMessageForSend()
if result == "" {
t.Error("Prepared message is empty")
}
// With repto
p.Repto = "hXzRNEzmMuzKkT1HCxUb"
result2 := p.PrepareMessageForSend()
if result2 == "" {
t.Error("Prepared message is empty")
}
if result == result2 {
t.Error("Messages with and without repto is equal!")
}
}