-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_histogram_test.go
60 lines (54 loc) · 1.38 KB
/
m_histogram_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
package metrics
import (
"testing"
client "github.com/influxdata/influxdb1-client"
"github.com/rcrowley/go-metrics"
"github.com/stretchr/testify/assert"
)
func Test_histogram_AddPoints(t *testing.T) {
type fields struct {
name string
measure string
tags map[string]string
}
type args struct {
pts []client.Point
}
tests := []struct {
name string
fields fields
args args
wantLen int
}{
{
name: "test AddPoints",
fields: fields{
measure: "measure1",
name: "testName",
tags: map[string]string{"fooby": "bar"},
},
args: args{},
wantLen: 12,
},
}
suffix := suffHistogram
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
metric := NewHistogram(tt.fields.name, WithTags(tt.fields.tags), WithMeasurement(tt.fields.measure))
metric.Update(5)
s := metrics.DefaultRegistry.Get(tt.fields.measure + "/" + tt.fields.name + suffix).(Metric)
got := s.AddPoints(tt.args.pts)
assert.Equal(t, tt.wantLen, len(got))
for _, point := range got {
for k, v := range tt.fields.tags {
assert.Contains(t, point.Tags, k)
assert.Contains(t, point.Tags[k], v)
}
assert.Contains(t, point.Tags, "bucket")
assert.Equal(t, len(tt.fields.tags)+1, len(point.Tags))
assert.Equal(t, tt.fields.measure, point.Measurement)
assert.Contains(t, point.Fields, tt.fields.name+suffix)
}
})
}
}