nunnatsa / ginkgolinter

golang linter for ginkgo and gomega
MIT License
27 stars 6 forks source link

[Enhancement] validate the `MatchError` gomega matcher #114

Closed pohly closed 1 year ago

pohly commented 1 year ago

Is your feature request related to a problem? Please describe.

https://github.com/onsi/gomega/commit/2b39142b16e69fa9405d5c7401dc62a5776a9bf5 in Gomega 1.29.0 extended MatchError so that a function + string is another valid option. It would be good to check for valid combinations of parameters via static analysis.

Valid:

Valid, but useless:

Invalid:

Additional context

In Kubernetes, we are replacing Expect(err).To(HaveOccurred()) or framework.ExpectError(err) with checks that the right error occurred. The callback functions are e.g. apierrors.IsNotFound.

nunnatsa commented 1 year ago

Sound good. Thanks for the idea, @pohly

And thanks for the tip. Implemented also here: https://github.com/kubevirt/hyperconverged-cluster-operator/pull/2578