-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Adding pointer support for HaveField
#494
Comments
One option would be to do it explicitly by using |
Hi @JoelSpeed @schrej, what about the Expect(foo).To(HaveField("bar", PointTo(baz))) This was inspired by this section of the docs, and I haven't tested it in this particular case: |
Oh nice, I didn't know about that one, and also not about I'd still like to have pointer support on HaveField("Foo.Bar.*Something.Deep") would be way more convenient compared to HaveField("Foo.Bar", PointTo(HaveField("Something.Deep", ...))) |
nope it's just an oversight. @blgm 's Will take a look at the PR @schrej submitted |
Done, thanks all. I've pulled in @schrej 's PR and published Gomega 1.18.1 |
I don't know if this was previously considered and vetoed for some reason, but I think it would be useful if
HaveField
would support pointers to structs and pointer substructs.I'm happy to put in some time to look into how we can modify the implementation and tests to add this support, just wanted to check if there was any reason not to do so before I propose it.
I'm thinking it would be useful if it could handle, for example:
But today this won't work as far as I can tell (we check at the beginning if the object is a struct).
If you need this in the meantime, this is what I've used in the past which has a similar usage but works with pointers:
The text was updated successfully, but these errors were encountered: