diff --git a/cmd/promtool/rules_test.go b/cmd/promtool/rules_test.go index 9f571ec23..1248c26bb 100644 --- a/cmd/promtool/rules_test.go +++ b/cmd/promtool/rules_test.go @@ -134,10 +134,7 @@ func TestBackfillRuleIntegration(t *testing.T) { series := selectedSeries.At() if len(series.Labels()) != 3 { require.Equal(t, 2, len(series.Labels())) - x := labels.Labels{ - labels.Label{Name: "__name__", Value: "grp2_rule1"}, - labels.Label{Name: "name1", Value: "val1"}, - } + x := labels.FromStrings("__name__", "grp2_rule1", "name1", "val1") require.Equal(t, x, series.Labels()) } else { require.Equal(t, 3, len(series.Labels())) @@ -259,10 +256,7 @@ func TestBackfillLabels(t *testing.T) { selectedSeries := q.Select(false, nil, labels.MustNewMatcher(labels.MatchRegexp, "", ".*")) for selectedSeries.Next() { series := selectedSeries.At() - expectedLabels := labels.Labels{ - labels.Label{Name: "__name__", Value: "rulename"}, - labels.Label{Name: "name1", Value: "value-from-rule"}, - } + expectedLabels := labels.FromStrings("__name__", "rulename", "name1", "value-from-rule") require.Equal(t, expectedLabels, series.Labels()) } require.NoError(t, selectedSeries.Err()) diff --git a/cmd/promtool/sd_test.go b/cmd/promtool/sd_test.go index 51fe59dac..82bc9947f 100644 --- a/cmd/promtool/sd_test.go +++ b/cmd/promtool/sd_test.go @@ -51,20 +51,20 @@ func TestSDCheckResult(t *testing.T) { expectedSDCheckResult := []sdCheckResult{ { - DiscoveredLabels: labels.Labels{ - labels.Label{Name: "__address__", Value: "localhost:8080"}, - labels.Label{Name: "__scrape_interval__", Value: "1m"}, - labels.Label{Name: "__scrape_timeout__", Value: "10s"}, - labels.Label{Name: "foo", Value: "bar"}, - }, - Labels: labels.Labels{ - labels.Label{Name: "__address__", Value: "localhost:8080"}, - labels.Label{Name: "__scrape_interval__", Value: "1m"}, - labels.Label{Name: "__scrape_timeout__", Value: "10s"}, - labels.Label{Name: "foo", Value: "bar"}, - labels.Label{Name: "instance", Value: "localhost:8080"}, - labels.Label{Name: "newfoo", Value: "bar"}, - }, + DiscoveredLabels: labels.FromStrings( + "__address__", "localhost:8080", + "__scrape_interval__", "1m", + "__scrape_timeout__", "10s", + "foo", "bar", + ), + Labels: labels.FromStrings( + "__address__", "localhost:8080", + "__scrape_interval__", "1m", + "__scrape_timeout__", "10s", + "foo", "bar", + "instance", "localhost:8080", + "newfoo", "bar", + ), Error: nil, }, }