Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldNordgren committed Jul 29, 2023
1 parent 3ec8430 commit fc8b99a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ func copyExportedFields(expected interface{}) interface{} {
}
}

// ObjectsExportedFieldsAreEqual determines if the exported (public) fields of two objects are
// considered equal. This comparison of only exported fields is applied recursively to nested data
// structures.
//
// This function does no assertion of any kind.
//
// Deprecated: Use EqualExportedValues instead.
func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool {
expectedCleaned := copyExportedFields(expected)
actualCleaned := copyExportedFields(actual)
return ObjectsAreEqualValues(expectedCleaned, actualCleaned)
}

// ObjectsAreEqualValues gets whether two objects are equal, or if their
// values are equal.
func ObjectsAreEqualValues(expected, actual interface{}) bool {
Expand Down
4 changes: 2 additions & 2 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ func TestEqualExportedValues(t *testing.T) {
}

for _, c := range cases {
t.Run(fmt.Sprintf("ObjectsExportedFieldsAreEqual(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
t.Run(fmt.Sprintf("EqualExportedValues(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
mockT := new(testing.T)
res := EqualExportedValues(mockT, c.expected, c.actual)

if res != c.result {
t.Errorf("ObjectsExportedFieldsAreEqual(%#v, %#v) should return %#v", c.expected, c.actual, c.result)
t.Errorf("EqualExportedValues(%#v, %#v) should return %#v", c.expected, c.actual, c.result)
}

})
Expand Down

0 comments on commit fc8b99a

Please sign in to comment.