-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhealth_test.go
40 lines (34 loc) · 990 Bytes
/
health_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
package consuldiscovery
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func getCurrentNodeName() string {
return "drnic.local"
}
func TestHealth(t *testing.T) {
Convey("HealthByNode", t, func() {
client := getClient(t)
checks, err := client.HealthByNode(getCurrentNodeName())
So(err, ShouldEqual, nil)
So(len(checks), ShouldEqual, 3)
})
Convey("HealthByState", t, func() {
client := getClient(t)
checks, err := client.HealthByState("critical")
So(err, ShouldEqual, nil)
So(len(checks), ShouldEqual, 1)
})
Convey("HealthByService", t, func() {
client := getClient(t)
nodes, err := client.HealthByService("simple_service")
So(err, ShouldEqual, nil)
So(len(nodes), ShouldEqual, 1)
node := nodes[0]
So(node.Service.ServiceID, ShouldEqual, "simple_service")
So(node.Service.ServiceName, ShouldEqual, "simple_service")
So(len(node.Checks), ShouldEqual, 3)
check := node.Checks[0]
So(check.Status, ShouldEqual, "passing")
})
}