You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
accept async functions with testing.TB variant instead of Gomega
In Kubernetes' ktesting package the following assertion is valid:
tCtx.Eventually(func(tCtx TContext)).Should(Succeed())
That works because tCtx.Eventually wraps the function such that failures
reported via tCtx.Error/Errorf/Fatal/Fatalf are 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.TB
methods 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.
Eventually(slowInt).WithPolling(time.Second*2).WithTimeout(time.Millisecond*100).Should(Equal(42)) // not valid, if validate-async-intervals flag is set
68
-
Eventually(slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in Eventually\. This actually checks nothing, because Eventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .Eventually\(slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
69
-
wrappers.MyEventually(slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in MyEventually\. This actually checks nothing, because MyEventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .wrappers.MyEventually\(slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
Eventually(slowInt).WithPolling(time.Second*2).WithTimeout(time.Millisecond*100).Should(Equal(42)) // not valid, if validate-async-intervals flag is set
68
+
Eventually(slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in Eventually\. This actually checks nothing, because Eventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .Eventually\(slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
69
+
wrappers.MyEventually(slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in MyEventually\. This actually checks nothing, because MyEventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .wrappers.MyEventually\(slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
70
+
Eventually(func() {}).Should(Succeed()) // want `ginkgo-linter: Success matcher only support a single error value, or function with Gomega as its first parameter`
71
+
wrappers.MyEventually(func() {}).Should(Succeed()) // want `ginkgo-linter: Success matcher only support a single error value, or function with Gomega as its first parameter`
Eventually(context.TODO(), slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in Eventually\. This actually checks nothing, because Eventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .Eventually\(context\.TODO\(\), slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
71
74
ctx:=context.TODO()
72
75
Eventually(ctx, slowInt()).WithPolling(time.Millisecond*100).WithTimeout(time.Second*2).Should(Equal(42)) // want `ginkgo-linter: use a function call in Eventually\. This actually checks nothing, because Eventually receives the function returned value, instead of function itself, and this value is never changed\. Consider using .Eventually\(ctx, slowInt\)\.WithPolling\(time\.Millisecond \* 100\)\.WithTimeout\(time\.Second \* 2\)\.Should\(Equal\(42\)\). instead`
0 commit comments