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
Equal, BeEquivalentTo, and BeComparableTo false positive on function types #570
Comments
Hey there -
If your goal is to make assertions on the non-function parts of a struct you can use Gomega's Sorry there isn't a more straightforward answer :/ |
Thanks for the details! I was able to get what I want using a go-cmp option. It's a little hacky, but it works. func TestCompareFunctions_Complete(t *testing.T) {
type Strategy func()
type Thing struct {
Strategy Strategy
}
var Strategy1 Strategy = func() {}
var Strategy2 Strategy = func() {}
thingA := Thing{Strategy: Strategy1}
thingB := Thing{Strategy: Strategy1}
thingC := Thing{Strategy: Strategy2}
strategyCompareOption := cmp.Transformer("strategy", func(s Strategy) string {
return fmt.Sprintf("%p", s)
})
g := NewWithT(t)
g.Expect(thingA).To(BeComparableTo(thingB, strategyCompareOption))
g.Expect(thingA).NotTo(BeComparableTo(thingC, strategyCompareOption))
}
|
Makes sense! Glad you were able to find a workaround. |
Hi. 👋 I'm getting a false positive when I compare two structs that have a function-type field.
This is using gomega version
v1.20.0
.Here's a minimal example:
And a more complete example to illustrate something closer to a real use case:
Click to expand...
The text was updated successfully, but these errors were encountered: