From 735914f692fd90759fe16f610f17a8e1d2767a5a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 9 Mar 2022 22:20:54 +0000 Subject: [PATCH] cmd/prometheus: in tests use labels.FromStrings Replacing code which assumes the internal structure of `Labels`. Signed-off-by: Bryan Boreham --- cmd/prometheus/main_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/prometheus/main_test.go b/cmd/prometheus/main_test.go index 2e1795c0b7..7dec5b9a59 100644 --- a/cmd/prometheus/main_test.go +++ b/cmd/prometheus/main_test.go @@ -147,8 +147,8 @@ func TestSendAlerts(t *testing.T) { { in: []*rules.Alert{ { - Labels: []labels.Label{{Name: "l1", Value: "v1"}}, - Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, + Labels: labels.FromStrings("l1", "v1"), + Annotations: labels.FromStrings("a2", "v2"), ActiveAt: time.Unix(1, 0), FiredAt: time.Unix(2, 0), ValidUntil: time.Unix(3, 0), @@ -156,8 +156,8 @@ func TestSendAlerts(t *testing.T) { }, exp: []*notifier.Alert{ { - Labels: []labels.Label{{Name: "l1", Value: "v1"}}, - Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, + Labels: labels.FromStrings("l1", "v1"), + Annotations: labels.FromStrings("a2", "v2"), StartsAt: time.Unix(2, 0), EndsAt: time.Unix(3, 0), GeneratorURL: "http://localhost:9090/graph?g0.expr=up&g0.tab=1", @@ -167,8 +167,8 @@ func TestSendAlerts(t *testing.T) { { in: []*rules.Alert{ { - Labels: []labels.Label{{Name: "l1", Value: "v1"}}, - Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, + Labels: labels.FromStrings("l1", "v1"), + Annotations: labels.FromStrings("a2", "v2"), ActiveAt: time.Unix(1, 0), FiredAt: time.Unix(2, 0), ResolvedAt: time.Unix(4, 0), @@ -176,8 +176,8 @@ func TestSendAlerts(t *testing.T) { }, exp: []*notifier.Alert{ { - Labels: []labels.Label{{Name: "l1", Value: "v1"}}, - Annotations: []labels.Label{{Name: "a2", Value: "v2"}}, + Labels: labels.FromStrings("l1", "v1"), + Annotations: labels.FromStrings("a2", "v2"), StartsAt: time.Unix(2, 0), EndsAt: time.Unix(4, 0), GeneratorURL: "http://localhost:9090/graph?g0.expr=up&g0.tab=1",