-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Equality matcher should not compare types #11
Comments
Ginkgo (the matcher library Gomega, actually) uses Golang's reflect.DeepEqual under the hood to do the equality matching (http://golang.org/pkg/reflect/#DeepEqual). I think Gomega's If all goes well with |
Hmm... so I've found a fix for this, but I'm conflicted about it. I can modify the Equality matcher so that it converts the actual value (the left hand side) to have the same value as the expected value (the right hand side) if such a conversion is possible. The converted actual is then passed in to This works with your string alias example, and doesn't break any other tests that I've written.... But it has the undesirable property that it will convert numbers... This would mean that the I'm inclined to leave the matcher as is: anal about types, and put the onus of converting types on to the developer. This does mean you'd need: Ω(info.User).Should(Equal(User("guest")) Which, while wordy, is actually nice and explicit -- (BTW I think That said, I'm open to discussion (and would love to have some discussion) about this. I could imagine a separate equality matcher that doesn't care about types.... but I'm not sure what I'd call it. |
As for the new matcher name, |
I think I'd prefer On Sat, Oct 26, 2013 at 9:19 PM, Michael Klishin
|
I agree. What do you think about |
I think |
Just added |
Thank you! |
* feat(add basic service auto-test): basic CRUD * fix(fix for auth): fix the configmap and secret client for auth
…atches Carry patches for OCP 4.15
I have some code that looks roughly like this:
However, this leads to failures. Explicit casting helps:
It may be that I'm too new to Go but I believe type aliases work the way I expect. But this is not the case with Ginkgo. So my theory is that the
Equal
matcher does type equality checking (not equivalence).At first I thought that's how Go works and stopped using type aliases, even though they make a lot of sense in my library.
So, is it a Go limitation or a Ginkgo "feature"?
The text was updated successfully, but these errors were encountered: