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

Function TestSignatureForLabels

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

SignatureForLabelsFunction · 0.85

Tested by

no test coverage detected