forked from dynport/metrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrix_test.go
43 lines (35 loc) · 1020 Bytes
/
metrix_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
package main
import (
"encoding/json"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestRiakStatus(t *testing.T) {
Convey("RiakStatus", t, func() {
m := &Riak{}
raw := readFile("fixtures/riak.json")
status, e := m.ParseRiakStatus(raw)
if e != nil {
t.Fatal(e.Error())
}
So(status.VNodeGets, ShouldEqual, int64(241))
So(status.NodePutFsmActive, ShouldEqual, int64(0))
So(status.CpuAvg1, ShouldEqual, int64(274))
So(len(status.ConnectedNodes), ShouldEqual, 4)
So(status.ConnectedNodes[0], ShouldEqual, "[email protected]")
So(len(status.RingMembers), ShouldEqual, 5)
So(status.RingMembers[0], ShouldEqual, "[email protected]")
})
}
func TestSerializeMetric(t *testing.T) {
Convey("SerializeMetric", t, func() {
m := &Metric{}
b, e := json.Marshal(m)
So(e, ShouldBeNil)
So(string(b), ShouldNotContainSubstring, "Tags")
m.Tags = map[string]string{"a": "b"}
b, e = json.Marshal(m)
So(e, ShouldBeNil)
So(string(b), ShouldContainSubstring, "Tags")
})
}