-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathconsul_test.go
62 lines (57 loc) · 1.26 KB
/
consul_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
57
58
59
60
61
62
package stretcher_test
import (
"bytes"
"testing"
"github.com/fujiwara/stretcher"
)
var ConsulInput1 = `[]`
var ConsulInput2 = `
[
{
"LTime": 2,
"Version": 1,
"TagFilter": "",
"ServiceFilter": "",
"NodeFilter": "",
"Payload": "czM6Ly9leGFtcGxlLmNvbS9wYXRoL3RvL3Rhci5neg==",
"Name": "deploy",
"ID": "1d6731a8-833c-1aff-94e5-aa5e5a77da9f"
},
{
"LTime": 3,
"Version": 1,
"TagFilter": "",
"ServiceFilter": "",
"NodeFilter": "",
"Payload": "czM6Ly9leGFtcGxlLmNvbS9wYXRoL3RvL2FwcC50YXIuZ3o=",
"Name": "deploy",
"ID": "b5ef1588-1bcd-d93f-5d9c-67cb6e8c4587"
}
]
`
func TestParseConsulEvents1(t *testing.T) {
in := bytes.NewReader([]byte(ConsulInput1))
ev, err := stretcher.ParseConsulEvents(in)
if err == nil {
t.Error(err)
}
if ev != nil {
t.Error("Input1 must be empty!")
}
}
func TestParseConsulEvents2(t *testing.T) {
in := bytes.NewReader([]byte(ConsulInput2))
ev, err := stretcher.ParseConsulEvents(in)
if err != nil {
t.Error(err)
}
if ev.ID != "b5ef1588-1bcd-d93f-5d9c-67cb6e8c4587" {
t.Error("invalid ID")
}
if ev.Name != "deploy" {
t.Error("invalid Name")
}
if string(ev.Payload) != "s3://example.com/path/to/app.tar.gz" {
t.Errorf("invalid Payload %s", string(ev.Payload))
}
}