accept async functions with testing.TB variant instead of Gomega #224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In Kubernetes' ktesting package the following assertion is valid:
That works because
tCtx.Eventuallywraps the function such that failures reported viatCtx.Error/Errorf/Fatal/Fatalfare visible to the matcher.Without this change, the "Success matcher only support a single error value, or function with Gomega as its first parameter" warning is triggered.
Instead of building in specific support for ktesting, the approach is to check for a first parameter which has any (not necessarily all!) of the
testing.TBmethods for reporting failures. That is considered a valid alternative to Gomega.There's now a potential false negative in the linter when passing such a function directly to gomega.Eventually/Consistently. That'll fail at runtime because gomega cannot call it, so such a false negative isn't too bad (fails reliably and obviously).
The warning message doesn't get changed because it would be confusing for most users to call out some vague alternative (vague because the linter has no details) that most users won't be able to use.
Fixes # (issue)
kubernetes/kubernetes#135664 (comment)
Type of change
How Has This Been Tested?
Checklist:
make goimports@nunnatsa