From 19578136aae1fda51fca55ffb85ff3f2b6727a2e Mon Sep 17 00:00:00 2001 From: Jim Fitzpatrick Date: Thu, 18 Jan 2024 16:50:38 +0000 Subject: [PATCH] Fix Integration Test --- controllers/gateway_kuadrant_controller_test.go | 8 ++++++-- controllers/helper_test.go | 5 +---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/controllers/gateway_kuadrant_controller_test.go b/controllers/gateway_kuadrant_controller_test.go index 374395856..bf10dce01 100644 --- a/controllers/gateway_kuadrant_controller_test.go +++ b/controllers/gateway_kuadrant_controller_test.go @@ -69,19 +69,21 @@ var _ = Describe("Kuadrant Gateway controller", func() { }) Context("Two kuadrant instances", func() { + var secondNamespace string BeforeEach(func() { + CreateNamespace(&secondNamespace) newKuadrantName := "second" newKuadrant := &kuadrantv1beta1.Kuadrant{ TypeMeta: metav1.TypeMeta{APIVersion: "v1beta1", Kind: "Kuadrant"}, - ObjectMeta: metav1.ObjectMeta{Name: newKuadrantName, Namespace: testNamespace}, + ObjectMeta: metav1.ObjectMeta{Name: newKuadrantName, Namespace: secondNamespace}, } err := testClient().Create(context.Background(), newKuadrant) Expect(err).ToNot(HaveOccurred()) Eventually(func() bool { kuadrant := &kuadrantv1beta1.Kuadrant{} - err := k8sClient.Get(context.Background(), client.ObjectKey{Name: newKuadrantName, Namespace: testNamespace}, kuadrant) + err := k8sClient.Get(context.Background(), client.ObjectKey{Name: newKuadrantName, Namespace: secondNamespace}, kuadrant) if err != nil { return false } @@ -92,6 +94,8 @@ var _ = Describe("Kuadrant Gateway controller", func() { }, time.Minute, 5*time.Second).Should(BeTrue()) }) + AfterEach(DeleteNamespaceCallback(&secondNamespace)) + It("new gateway should not be annotated", func() { gateway := testBuildBasicGateway(gwName, testNamespace) err := k8sClient.Create(context.Background(), gateway) diff --git a/controllers/helper_test.go b/controllers/helper_test.go index dd7b8583f..910a5596f 100644 --- a/controllers/helper_test.go +++ b/controllers/helper_test.go @@ -62,10 +62,7 @@ func CreateNamespace(namespace *string) { existingNamespace := &v1.Namespace{} Eventually(func() bool { err := testClient().Get(context.Background(), types.NamespacedName{Name: generatedTestNamespace}, existingNamespace) - if err != nil { - return false - } - return true + return err == nil }, time.Minute, 5*time.Second).Should(BeTrue()) *namespace = existingNamespace.Name