Simplify Labels.Equals()

Also extend the Compare() tests to also test Labels.Equals().
This commit is contained in:
Julius Volz 2017-04-28 15:53:48 +02:00
parent a5322c50fc
commit a25f874ec4
2 changed files with 3 additions and 2 deletions

View file

@ -84,7 +84,7 @@ func (ls Labels) Equals(o Labels) bool {
return false
}
for i, l := range ls {
if l.Name != o[i].Name || l.Value != o[i].Value {
if o[i] != l {
return false
}
}

View file

@ -28,7 +28,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestCompare(t *testing.T) {
func TestCompareAndEquals(t *testing.T) {
cases := []struct {
a, b []Label
res int
@ -88,6 +88,7 @@ func TestCompare(t *testing.T) {
a, b := New(c.a...), New(c.b...)
require.Equal(t, c.res, Compare(a, b))
require.Equal(t, c.res == 0, a.Equals(b))
}
}