Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

property: fix panic in equality check of property value #104

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
}