forked from mirror/client_golang
make code compatible with go 1.6
This commit is contained in:
parent
685a3c90d4
commit
555018f3c9
|
@ -78,33 +78,28 @@ func TestCounterVecGetMetricWithInvalidLabelValues(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
test := test
|
counterVec := NewCounterVec(CounterOpts{
|
||||||
t.Run(test.desc, func(t *testing.T) {
|
Name: "test",
|
||||||
t.Parallel()
|
}, []string{"a"})
|
||||||
|
|
||||||
counterVec := NewCounterVec(CounterOpts{
|
labelValues := make([]string, len(test.labels))
|
||||||
Name: "test",
|
for _, val := range test.labels {
|
||||||
}, []string{"a"})
|
labelValues = append(labelValues, val)
|
||||||
|
}
|
||||||
|
|
||||||
labelValues := make([]string, len(test.labels))
|
expectPanic(t, func() {
|
||||||
for _, val := range test.labels {
|
counterVec.WithLabelValues(labelValues...)
|
||||||
labelValues = append(labelValues, val)
|
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
||||||
}
|
expectPanic(t, func() {
|
||||||
|
counterVec.With(test.labels)
|
||||||
|
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
||||||
|
|
||||||
expectPanic(t, func() {
|
if _, err := counterVec.GetMetricWithLabelValues(labelValues...); err == nil {
|
||||||
counterVec.WithLabelValues(labelValues...)
|
t.Errorf("GetMetricWithLabelValues: expected error because: %s", test.desc)
|
||||||
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
}
|
||||||
expectPanic(t, func() {
|
if _, err := counterVec.GetMetricWith(test.labels); err == nil {
|
||||||
counterVec.With(test.labels)
|
t.Errorf("GetMetricWith: expected error because: %s", test.desc)
|
||||||
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
}
|
||||||
|
|
||||||
if _, err := counterVec.GetMetricWithLabelValues(labelValues...); err == nil {
|
|
||||||
t.Errorf("GetMetricWithLabelValues: expected error because: %s", test.desc)
|
|
||||||
}
|
|
||||||
if _, err := counterVec.GetMetricWith(test.labels); err == nil {
|
|
||||||
t.Errorf("GetMetricWith: expected error because: %s", test.desc)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,24 +25,19 @@ func TestNewConstMetricInvalidLabelValues(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
test := test
|
metricDesc := NewDesc(
|
||||||
t.Run(test.desc, func(t *testing.T) {
|
"sample_value",
|
||||||
t.Parallel()
|
"sample value",
|
||||||
|
[]string{"a"},
|
||||||
|
Labels{},
|
||||||
|
)
|
||||||
|
|
||||||
metricDesc := NewDesc(
|
expectPanic(t, func() {
|
||||||
"sample_value",
|
MustNewConstMetric(metricDesc, CounterValue, 0.3, "\xFF")
|
||||||
"sample value",
|
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
||||||
[]string{"a"},
|
|
||||||
Labels{},
|
|
||||||
)
|
|
||||||
|
|
||||||
expectPanic(t, func() {
|
if _, err := NewConstMetric(metricDesc, CounterValue, 0.3, "\xFF"); err == nil {
|
||||||
MustNewConstMetric(metricDesc, CounterValue, 0.3, "\xFF")
|
t.Errorf("NewConstMetric: expected error because: %s", test.desc)
|
||||||
}, fmt.Sprintf("WithLabelValues: expected panic because: %s", test.desc))
|
}
|
||||||
|
|
||||||
if _, err := NewConstMetric(metricDesc, CounterValue, 0.3, "\xFF"); err == nil {
|
|
||||||
t.Errorf("NewConstMetric: expected error because: %s", test.desc)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue