From 63b09944b8502a64cb17330161c8520d24874aa4 Mon Sep 17 00:00:00 2001 From: gotjosh Date: Tue, 30 Apr 2024 12:25:48 +0100 Subject: [PATCH] Use labels.Len() instead of manually counting the labels Signed-off-by: gotjosh --- rules/alerting_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rules/alerting_test.go b/rules/alerting_test.go index 165f38b86..5fae3edd1 100644 --- a/rules/alerting_test.go +++ b/rules/alerting_test.go @@ -711,16 +711,12 @@ func TestQueryForStateSeries(t *testing.T) { ) sample := rule.forStateSample(nil, time.Time{}, 0) - var matchersCount int - sample.Metric.Range(func(l labels.Label) { - matchersCount++ - }) seriesSet, err := rule.QueryForStateSeries(context.Background(), querier) var series storage.Series for seriesSet.Next() { - if seriesSet.At().Labels().Len() == matchersCount { + if seriesSet.At().Labels().Len() == sample.Metric.Len() { series = seriesSet.At() break }