-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
RFC: new BeInMapKeys
matcher
#589
Comments
I think 1 would be in keeping with how similar matchers work. But I'm wondering about the use case for
intended to behave differently from
|
var names = map[string]struct {
projectname string
}{
"edgy_emil": {projectname: "foobar_project"},
"furious_freddy": {projectname: "foobar_project"},
}
var canaries []*Container
Expect(workload).To(ContainElement(HaveField("Name", BeInMapKeys(names)), &canaries))
Expect(canaries).To(HaveLen(len(names))) et voilà, this asserts that all canaries are (still) present in the container workload and that we get a nicely filtered list of these canaries, filtering out the other workload "noise". |
ah I see. brilliant. I also came a cross a use case for |
You're lucky ... because I wrote lots of this range-test-and-append boilerplate until I finally saw that the dual-use of |
Hopefully, a
BeInMapKeys
might be helpful to fellow test spec writers and not only to me?BeInMapKeys
checksactual
to be one of the keys of the map specified to the matcher. I can supply a PR if there is interest.Regarding the implementation of a
BeInMapKeys
matcher I would like to get feedback on how to check theactual
, as I see two different approaches and am unsure as to which one would be the better one:actual
against the list of keys using theEqual()
matcher;actual
key, so without usingEqual()
at all. This requiresactual
to be of the exact key type, if I'm not mistaken.What would be the preferred method: 1. or 2.?
The text was updated successfully, but these errors were encountered: