1
0
Fork 0

chore: update linter

This commit is contained in:
Ludovic Fernandez 2023-11-17 01:50:06 +01:00 committed by GitHub
parent 12e50e20e6
commit 553ef94047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 129 additions and 105 deletions

View file

@ -427,12 +427,12 @@ func TestPrometheus(t *testing.T) {
return
}
for _, label := range family.Metric[0].Label {
val, ok := test.labels[*label.Name]
for _, label := range family.GetMetric()[0].GetLabel() {
val, ok := test.labels[label.GetName()]
if !ok {
t.Errorf("%q metric contains unexpected label %q", test.name, *label.Name)
} else if val != *label.Value {
t.Errorf("label %q in metric %q has wrong value %q, expected %q", *label.Name, test.name, *label.Value, val)
t.Errorf("%q metric contains unexpected label %q", test.name, label.GetName())
} else if val != label.GetValue() {
t.Errorf("label %q in metric %q has wrong value %q, expected %q", label.GetName(), test.name, label.GetValue(), val)
}
}
test.assert(family)
@ -683,7 +683,7 @@ func findMetricByLabelNamesValues(family *dto.MetricFamily, labelNamesValues ...
return nil
}
for _, metric := range family.Metric {
for _, metric := range family.GetMetric() {
if hasMetricAllLabelPairs(metric, labelNamesValues...) {
return metric
}
@ -703,7 +703,7 @@ func hasMetricAllLabelPairs(metric *dto.Metric, labelNamesValues ...string) bool
}
func hasMetricLabelPair(metric *dto.Metric, labelName, labelValue string) bool {
for _, labelPair := range metric.Label {
for _, labelPair := range metric.GetLabel() {
if labelPair.GetName() == labelName && labelPair.GetValue() == labelValue {
return true
}
@ -720,12 +720,12 @@ func assertCounterValue(t *testing.T, want float64, family *dto.MetricFamily, la
t.Error("metric must not be nil")
return
}
if metric.Counter == nil {
if metric.GetCounter() == nil {
t.Errorf("metric %s must be a counter", family.GetName())
return
}
if cv := metric.Counter.GetValue(); cv != want {
if cv := metric.GetCounter().GetValue(); cv != want {
t.Errorf("metric %s has value %v, want %v", family.GetName(), cv, want)
}
}
@ -734,7 +734,7 @@ func buildCounterAssert(t *testing.T, metricName string, expectedValue int) func
t.Helper()
return func(family *dto.MetricFamily) {
if cv := int(family.Metric[0].Counter.GetValue()); cv != expectedValue {
if cv := int(family.GetMetric()[0].GetCounter().GetValue()); cv != expectedValue {
t.Errorf("metric %s has value %d, want %d", metricName, cv, expectedValue)
}
}
@ -744,7 +744,7 @@ func buildGreaterThanCounterAssert(t *testing.T, metricName string, expectedMinV
t.Helper()
return func(family *dto.MetricFamily) {
if cv := int(family.Metric[0].Counter.GetValue()); cv < expectedMinValue {
if cv := int(family.GetMetric()[0].GetCounter().GetValue()); cv < expectedMinValue {
t.Errorf("metric %s has value %d, want at least %d", metricName, cv, expectedMinValue)
}
}
@ -754,7 +754,7 @@ func buildHistogramAssert(t *testing.T, metricName string, expectedSampleCount i
t.Helper()
return func(family *dto.MetricFamily) {
if sc := int(family.Metric[0].Histogram.GetSampleCount()); sc != expectedSampleCount {
if sc := int(family.GetMetric()[0].GetHistogram().GetSampleCount()); sc != expectedSampleCount {
t.Errorf("metric %s has sample count value %d, want %d", metricName, sc, expectedSampleCount)
}
}
@ -764,7 +764,7 @@ func buildGaugeAssert(t *testing.T, metricName string, expectedValue int) func(f
t.Helper()
return func(family *dto.MetricFamily) {
if gv := int(family.Metric[0].Gauge.GetValue()); gv != expectedValue {
if gv := int(family.GetMetric()[0].GetGauge().GetValue()); gv != expectedValue {
t.Errorf("metric %s has value %d, want %d", metricName, gv, expectedValue)
}
}
@ -774,7 +774,7 @@ func buildTimestampAssert(t *testing.T, metricName string) func(family *dto.Metr
t.Helper()
return func(family *dto.MetricFamily) {
if ts := time.Unix(int64(family.Metric[0].Gauge.GetValue()), 0); time.Since(ts) > time.Minute {
if ts := time.Unix(int64(family.GetMetric()[0].GetGauge().GetValue()), 0); time.Since(ts) > time.Minute {
t.Errorf("metric %s has wrong timestamp %v", metricName, ts)
}
}