-
Notifications
You must be signed in to change notification settings - Fork 25
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
Added ability to ignore fields by tagging them. #12
Conversation
Added code and tests to support tagging fields with testdiff:"ignore". Adding this tag to any field will make messagediff skip this field. This is useful for transient fields that do not store actual value of the struct. I have used generic 'testdiff' tag to potentially make it usable by other libraries who might want to do the same purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
README.md
Outdated
a := someStruct{1, 2, []int{1}} | ||
b := someStruct{1, 3, []int{1, 2}} | ||
a := someStruct{1, 2, []int{1}, 9} | ||
b := someStruct{1, 3, []int{1, 2}, 10} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should add as a separate example to show off this feature since most people won't care about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to create a new test case, or to create a new Test with it's own struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I separated the test for ignoring fields into a separate test altogether.
I mistakenly thought your review comment related to actual tests and not README... I fixed it in docs now. I also corrected indentation of the code in README. |
Added code and tests to support tagging fields with testdiff:"ignore".
Adding this tag to any field will make messagediff skip this field.
This is useful for transient fields that do not store actual value of
the struct. I have used generic 'testdiff' tag to potentially make it
usable by other libraries who might want to do the same purpose.