testify icon indicating copy to clipboard operation
testify copied to clipboard

Impossible to just compare public elements of a struct.

Open rsheasby opened this issue 4 years ago • 2 comments

Hi there. Firstly, thanks for the great library. I've only run into one gripe so far.

There doesn't seem to be a way to compare only the public fields of a struct. For some reason assert.Equal compares private fields too. Why do I need this? To compare protobuf messages. The public fields are the actual valuable info, and the private fields are implementation details like "sizeCache" which are unimportant but still frequently different.

rsheasby avatar Dec 21 '20 20:12 rsheasby

Agreed. Python's equivalent of mock.Anything (mock.ANY) also works for equality comparisons. However, I'm not saying that just because it works that way in Python it should also be the same here. That aside, there's already an existing discussion here: https://github.com/stretchr/testify/issues/758

chuckoy avatar Jan 13 '21 23:01 chuckoy

Working on this!

mchlp avatar Nov 28 '22 03:11 mchlp