diff --git a/item.go b/item.go index 87d52d8..95aa39c 100644 --- a/item.go +++ b/item.go @@ -16,7 +16,7 @@ func ItemsEqual(it, with Item) bool { if IsNil(it) || IsNil(with) { return with == it } - result := true + result := false if it.IsCollection() { if it.GetType() == CollectionOfItems { OnItemCollection(it, func(c *ItemCollection) error { @@ -115,4 +115,4 @@ func IsNil(it Item) bool { }) } return isNil -} \ No newline at end of file +} diff --git a/item_test.go b/item_test.go index 3013c82..ccccdf4 100644 --- a/item_test.go +++ b/item_test.go @@ -188,4 +188,61 @@ func TestIsNil(t *testing.T) { } }) } -} \ No newline at end of file +} + +func TestItemsEqual1(t *testing.T) { + type args struct { + it Item + with Item + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "nil", + args: args{}, + want: true, + }, + { + name: "equal empty items", + args: args{ + it: &Object{}, + with: &Actor{}, + }, + want: true, + }, + { + name: "equal same ID items", + args: args{ + it: &Object{ID: "example-1"}, + with: &Object{ID: "example-1"}, + }, + want: true, + }, + { + name: "different IDs", + args: args{ + it: &Object{ID: "example-1"}, + with: &Object{ID: "example-2"}, + }, + want: false, + }, + { + name: "different properties", + args: args{ + it: &Object{ID: "example-1"}, + with: &Object{Type: ArticleType}, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := ItemsEqual(tt.args.it, tt.args.with); got != tt.want { + t.Errorf("ItemsEqual() = %v, want %v", got, tt.want) + } + }) + } +}