Open navijation opened 3 weeks ago
Thanks @navijatio. I love this idea. I would make it even strict: to force only the checked value to be only a function call, that only returns one value of error type.
Do you want to implement this?
@nunnatsa yeah that makes sense, Expect(err).To(Not(Suceed())
doesn't feel very readable. I'll see if I or anyone I know can take this on this week.
Thinking about it again, this is a good linter rule, but I think the real fix will be to fix the Succeed
matcher itself, to always check the last return value, if it's a nil error, ignoring the rest of the return values, and won't limit itself to a single return value.
For example, this is a very common patterns when using gomega:
_, err := funcReturnsValueAndError()
Expect(err).ToNot(HaveOccurred())
...
Expect(funcReturnsOnlyError()).To(Succeed())
I think it makes more sense that the this code will work:
Expect(funcReturnsValueAndError()).To(Succeed())
...
Expect(funcReturnsOnlyError()).To(Succeed())
@onsi - what do you think?
Is your feature request related to a problem? Please describe.
To(Succeed())
in Ginkgo has the rather peculiar behavior of failing when theExpect
takes in multiple arguments. It is considered a misuse to useSucceed
in this context according to Gomega docs.Describe the solution you'd like Report an error if
Expect(someFunction()).To(Succeed())
is called and the function returns multiple values, or if the number of arguments toExpect
here is greater than 1.Describe alternatives you've considered N/A
Additional context N/A