-
Notifications
You must be signed in to change notification settings - Fork 0
/
countervec3_test.go
71 lines (62 loc) · 1.34 KB
/
countervec3_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
package promvec
import (
"testing"
"github.com/prometheus/client_golang/prometheus"
)
func TestCounterVec3Empty(t *testing.T) {
var (
desc = make(chan *prometheus.Desc, 10)
coll = make(chan prometheus.Metric, 10)
)
v := NewCounterVec3(
prometheus.CounterOpts{
Name: "test",
Help: "test",
ConstLabels: nil,
},
[3]string{},
[][3]string{},
)
v.Describe(desc)
d, ok := <-desc
if !ok || d == nil || len(d.String()) == 0 {
t.Errorf("no description")
}
v.Collect(coll)
if have, want := len(coll), 0; have != want {
t.Errorf("have %v, want %v", have, want)
}
}
func TestCounterVec3(t *testing.T) {
var (
desc = make(chan *prometheus.Desc, 10)
coll = make(chan prometheus.Metric, 10)
)
v := NewCounterVec3(
prometheus.CounterOpts{
Name: "test",
Help: "test",
ConstLabels: nil,
},
[...]string{"first", "second", "third"},
[][3]string{
{"a", "b", "eee"},
{"aa", "bb", "eee"},
{"aa", "cc", "eee"},
},
)
v.Describe(desc)
d, ok := <-desc
if !ok || d == nil || len(d.String()) == 0 {
t.Errorf("no description")
}
v.Collect(coll)
if have, want := len(coll), 3; have != want {
t.Errorf("have %v, want %v", have, want)
}
c := v.WithLabelValues([...]string{"aa", "bb", "eee"})
d = c.Desc()
if d == nil || len(d.String()) == 0 {
t.Errorf("no counter description")
}
}