mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
labels: test Compare without knowing the exact result
Only the sign of the result is important Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
a6c6155092
commit
fb2d883f1e
|
@ -503,9 +503,19 @@ func TestLabels_Compare(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sign := func(a int) int {
|
||||||
|
switch {
|
||||||
|
case a < 0:
|
||||||
|
return -1
|
||||||
|
case a > 0:
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
got := Compare(labels, test.compared)
|
got := Compare(labels, test.compared)
|
||||||
require.Equal(t, test.expected, got, "unexpected comparison result for test case %d", i)
|
require.Equal(t, sign(test.expected), sign(got), "unexpected comparison result for test case %d", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue