From 5a3257a291122f60253000f893b4a4ac3a90eb64 Mon Sep 17 00:00:00 2001 From: Dimitris Gkanatsios Date: Tue, 14 Jun 2022 01:45:27 -0700 Subject: [PATCH] fixing webhook test --- .../api/v1alpha1/gameserverbuild_webhook_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/operator/api/v1alpha1/gameserverbuild_webhook_test.go b/pkg/operator/api/v1alpha1/gameserverbuild_webhook_test.go index 5bbfe29d..be7c9b44 100644 --- a/pkg/operator/api/v1alpha1/gameserverbuild_webhook_test.go +++ b/pkg/operator/api/v1alpha1/gameserverbuild_webhook_test.go @@ -3,12 +3,19 @@ package v1alpha1 import ( "math/rand" "os" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + timeout = time.Second * 5 + interval = time.Millisecond * 250 ) var _ = Describe("GameServerBuild webhook tests", func() { @@ -19,6 +26,12 @@ var _ = Describe("GameServerBuild webhook tests", func() { buildName2, _ := getNewNameAndID() gsb := createTestGameServerBuild(buildName, buildID, 2, 4, false) Expect(k8sClient.Create(ctx, &gsb)).Should(Succeed()) + // make sure the new GameServerBuild is part of the cache + var gsbTest GameServerBuild + Eventually(func() bool { + err := k8sClient.Get(ctx, client.ObjectKey{Name: buildName, Namespace: "default"}, &gsbTest) + return err == nil + }, timeout, interval).Should(BeTrue()) gsb = createTestGameServerBuild(buildName2, buildID, 2, 4, false) err := k8sClient.Create(ctx, &gsb) Expect(err).To(HaveOccurred())