mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Merge pull request #68 from prometheus/simplify-equals
Simplify Labels.Equals()
This commit is contained in:
commit
006f5d6b22
|
@ -84,7 +84,7 @@ func (ls Labels) Equals(o Labels) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for i, l := range ls {
|
for i, l := range ls {
|
||||||
if l.Name != o[i].Name || l.Value != o[i].Value {
|
if o[i] != l {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCompare(t *testing.T) {
|
func TestCompareAndEquals(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
a, b []Label
|
a, b []Label
|
||||||
res int
|
res int
|
||||||
|
@ -88,6 +88,7 @@ func TestCompare(t *testing.T) {
|
||||||
a, b := New(c.a...), New(c.b...)
|
a, b := New(c.a...), New(c.b...)
|
||||||
|
|
||||||
require.Equal(t, c.res, Compare(a, b))
|
require.Equal(t, c.res, Compare(a, b))
|
||||||
|
require.Equal(t, c.res == 0, a.Equals(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue