-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
DeepEqual comparison should tell you what's not equal #216
Comments
@benmoss would that introduce a new, third-party dependency to Gomega? If so, I foresee this causing pain for consumers of this library. Is it better to re-implement that logic inside gomega than pull in a dependency? |
+1 to reimplementing. This is dangerous territory... asserting equality can be tricky business in Go and relying on DeepEqual is a safe way to do so. Maintaining control over the code would be key. |
My response wasn't very clear. I would love to have improved diff identification in Gomega. I'd want the code that does equality to be:
Does that make sense? |
Yup, I'm gonna try to work on this now! |
ok after looking at this for a lil bit it seems way too hard to reimplement, my reflect-fu is far too lacking |
I ended up making my own lib for this, in case anyone wants it: https://github.com/benmoss/matchers/ The burden of the criteria needed to be included in Gomega itself was just too high, so it's better to be a buyer-beware third party thing :). |
Did you ever consider to depend on https://github.com/google/go-cmp? |
hey I hesitate to change the |
A separate comparer sounds good. We have set it up like this for now: https://github.com/kubernetes-sigs/kueue/blob/main/pkg/util/testing/equal_cmp.go |
/reopen |
yes, exactly like that. I could also imagine a configurable flag on Gomega that would cause |
Hey, the Gomega equality operation still fails on time comparison as @sedyh noted on #264 (comment). |
I'm on board with moving in this direction - but I'm a bit underwater with other projects at the moment. If there's anyone with bandwidth and interest to work on a PR I'd be happy to talk through a design that would allow users to use |
@xiantank just added |
@onsi I find the description of |
Hey @ilearnio - which description are you referring to? The godocs are simply trying to say "this matcher uses |
@onsi Yeah, I'm referring to that description. It took me a while to understand that |
Thanks @ilearnio - I've updated the docs to try and make it a bit clearer and pushed out a change. |
@onsi Awesome! Thanks a lot bro |
Right now when you use
Expect(..).To(Equal(...))
and it uses go's DeepEqual function, it doesn't really help you find what is not equal. I just spent a bunch of time trying to figure out that an interface field was using a value type instead of a pointer.Along the way I found https://godoc.org/github.com/juju/testing/checkers#DeepEqual, which is an alternate implementation of DeepEqual that actually will show you the differences. Would you consider a PR that changed gomega
Equal
to use this instead?The text was updated successfully, but these errors were encountered: