-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ignore fields using struct tags #843
Comments
Not that I am aware of, would it make sense in your use case to explicitly assert the fields (if the include list is small) or conversely shallow-copy the struct and remove the ones you don't want to compare (if the exclude list is small)? |
Hello. Is there any news on this? I have the issue described, and I cannot use the suggested ways of @boyan-soubachov because it's intricated controllers so I don't get to manipulate the intermediate result used by the mock. |
I think this could be a good approach for the issues people face with comparing nested time.Time objects and unsorted array types? Struct tags could override the comparison used, for example: my_code.go ...
type MyAmazingThing struct {
ID string
Created time.Time
Documents []string
DeleteFn func() error
}
... my_code_test.go ...
type myAmazingThingEqual struct {
ID string
Created time.Time // `testify:"WithinDuration,0"`
Documents []string // `testify:"ElementsMatch"`
DeleteFn func() error // `testify:"ignore"`
}
assert.Equal(t, expected, myAmazingThingEqual(actual))
... |
Hello,
Is there a way to ignore certain fields when asserting equal or as the argument of .On?
e.g.
We don't really care about the UpdateAt time, and this would also apply to random UUID's etc.
Otherwise we would have to assert each sub field in order for the test to pass.
The text was updated successfully, but these errors were encountered: