-
Notifications
You must be signed in to change notification settings - Fork 82
/
label_test.go
54 lines (49 loc) · 924 Bytes
/
label_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
package tstorage
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMarshalMetricName(t *testing.T) {
tests := []struct {
name string
metric string
labels []Label
want string
}{
{
name: "only metric",
metric: "metric1",
want: "metric1",
},
{
name: "missing label name",
metric: "metric1",
labels: []Label{
{Value: "value1"},
},
want: "\x00\ametric1",
},
{
name: "missing label value",
metric: "metric1",
labels: []Label{
{Name: "metric1"},
},
want: "\x00\ametric1",
},
{
name: "metric with a single label",
metric: "metric1",
labels: []Label{
{Name: "name1", Value: "value1"},
},
want: "\x00\ametric1\x00\x05name1\x00\x06value1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := marshalMetricName(tt.metric, tt.labels)
assert.Equal(t, tt.want, got)
})
}
}