Skip to content

Commit 5a2508c

Browse files
committed
Replace require.Eventually with kcptestinghelpers.Eventually
Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent 9cf79c5 commit 5a2508c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/e2e/apibinding/apibinding_webhook_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
admissionv1 "k8s.io/api/admission/v1"
3131
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
32-
"k8s.io/apimachinery/pkg/api/errors"
32+
apierrors "k8s.io/apimachinery/pkg/api/errors"
3333
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434
"k8s.io/apimachinery/pkg/runtime"
3535
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -197,14 +197,13 @@ func TestAPIBindingMutatingWebhook(t *testing.T) {
197197

198198
// Avoid race condition here by making sure that CRD is served after installing the types into logical clusters
199199
t.Logf("Creating cowboy resource in target logical cluster")
200-
require.Eventually(t, func() bool {
201-
_, err = cowbyClusterClient.Cluster(targetPath).WildwestV1alpha1().Cowboys("default").Create(ctx, &cowboy, metav1.CreateOptions{})
202-
t.Log(err)
203-
if err != nil && !errors.IsAlreadyExists(err) {
204-
return false
200+
kcptestinghelpers.Eventually(t, func() (bool, string) {
201+
_, err := cowbyClusterClient.Cluster(targetPath).WildwestV1alpha1().Cowboys("default").Create(ctx, &cowboy, metav1.CreateOptions{})
202+
if err != nil && !apierrors.IsAlreadyExists(err) {
203+
return false, err.Error()
205204
}
206-
return testWebhooks[sourcePath].Calls() >= 1
207-
}, wait.ForeverTestTimeout, 100*time.Millisecond)
205+
return testWebhooks[sourcePath].Calls() >= 1, ""
206+
}, wait.ForeverTestTimeout, 100*time.Millisecond, "failed to create cowboy resource")
208207

209208
t.Logf("Check that the in-workspace webhook was NOT called")
210209
require.Zero(t, testWebhooks[targetPath].Calls(), "in-workspace webhook should not have been called")

0 commit comments

Comments
 (0)