MCPcopy Create free account
hub / github.com/prometheus/common / TestSignatureForLabels

Function TestSignatureForLabels

model/signature_test.go:97–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestSignatureForLabels(t *testing.T) {
98 scenarios := []struct {
99 in Metric
100 labels LabelNames
101 out uint64
102 }{
103 {
104 in: Metric{},
105 labels: nil,
106 out: 14695981039346656037,
107 },
108 {
109 in: Metric{},
110 labels: LabelNames{"empty"},
111 out: 7187873163539638612,
112 },
113 {
114 in: Metric{"name": "garland, briggs", "fear": "love is not enough"},
115 labels: LabelNames{"empty"},
116 out: 7187873163539638612,
117 },
118 {
119 in: Metric{"name": "garland, briggs", "fear": "love is not enough"},
120 labels: LabelNames{"fear", "name"},
121 out: 5799056148416392346,
122 },
123 {
124 in: Metric{"name": "garland, briggs", "fear": "love is not enough", "foo": "bar"},
125 labels: LabelNames{"fear", "name"},
126 out: 5799056148416392346,
127 },
128 {
129 in: Metric{"name": "garland, briggs", "fear": "love is not enough"},
130 labels: LabelNames{},
131 out: 14695981039346656037,
132 },
133 {
134 in: Metric{"name": "garland, briggs", "fear": "love is not enough"},
135 labels: nil,
136 out: 14695981039346656037,
137 },
138 }
139
140 for i, scenario := range scenarios {
141 actual := SignatureForLabels(scenario.in, scenario.labels...)
142
143 if actual != scenario.out {
144 t.Errorf("%d. expected %d, got %d", i, scenario.out, actual)
145 }
146 }
147}
148
149func TestSignatureWithoutLabels(t *testing.T) {
150 scenarios := []struct {

Callers

nothing calls this directly

Calls 1

SignatureForLabelsFunction · 0.85

Tested by

no test coverage detected