Skip to content

Commit

Permalink
property: fix panic in equality check of property value (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasparada authored Jul 31, 2024
1 parent e85ed4e commit b875b1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion property/property.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package property

import (
"reflect"
"strings"

"golang.org/x/exp/slices"
Expand Down Expand Up @@ -92,7 +93,7 @@ func (pp *Properties) Add(key string, value any) {

func (pp Properties) Equal(target Properties) bool {
return slices.EqualFunc(pp, target, func(a, b Property) bool {
return a.Key == b.Key && a.Value == b.Value
return a.Key == b.Key && reflect.DeepEqual(a.Value, b.Value)
})
}

Expand Down
19 changes: 19 additions & 0 deletions property/property_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package property

import (
"testing"

"github.com/alecthomas/assert/v2"
)

func TestProperties_Equal(t *testing.T) {
assert.NotPanics(t, func() {
p1 := Properties{
{Key: "key1", Value: []any{"value1"}},
}
p2 := Properties{
{Key: "key1", Value: []any{"value1"}},
}
p1.Equal(p2)
})
}

0 comments on commit b875b1a

Please sign in to comment.