forked from prometheus-community/rsyslog_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointstore_test.go
92 lines (73 loc) · 1.38 KB
/
pointstore_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import "testing"
func TestPointStore(t *testing.T) {
ps := newPointStore()
s1 := &point{
Name: "my counter",
Type: counter,
Value: int64(10),
}
s2 := &point{
Name: "my counter",
Type: counter,
Value: int64(5),
}
err := ps.set(s1)
if err != nil {
t.Error(err)
}
got, err := ps.get(s1.key())
if err != nil {
t.Error(err)
}
if want, got := int64(10), got.Value; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
err = ps.set(s2)
if err != nil {
t.Error(err)
}
got, err = ps.get(s2.key())
if err != nil {
t.Error(err)
}
if want, got := int64(5), got.Value; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
s3 := &point{
Name: "my gauge",
Type: gauge,
Value: int64(20),
}
err = ps.set(s3)
if err != nil {
t.Error(err)
}
got, err = ps.get(s3.key())
if err != nil {
t.Error(err)
}
if want, got := int64(20), got.Value; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
s4 := &point{
Name: "my gauge",
Type: gauge,
Value: int64(15),
}
err = ps.set(s4)
if err != nil {
t.Error(err)
}
got, err = ps.get(s4.key())
if err != nil {
t.Error(err)
}
if want, got := int64(15), got.Value; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
_, err = ps.get("no point")
if err != errPointNotFound {
t.Error("getting non existent point should raise error")
}
}