mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 16:02:28 +00: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 {
|
||||
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 New Issue
Block a user