mirror of https://github.com/prometheus/prometheus
cmd/promtool: in tests use labels.FromStrings
Replacing code which assumes the internal structure of `Labels`. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>pull/11292/head
parent
8297f5cb6b
commit
c438b50133
|
@ -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())
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue