From e0b339d68a45d0e99572de5a62fcbe277a962992 Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Thu, 9 Jun 2022 17:28:50 +0200 Subject: [PATCH] fix(tests): cleaning up protected tenant upon test success --- e2e/tenant_protected_webhook_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/e2e/tenant_protected_webhook_test.go b/e2e/tenant_protected_webhook_test.go index e80039b8..108f35e5 100644 --- a/e2e/tenant_protected_webhook_test.go +++ b/e2e/tenant_protected_webhook_test.go @@ -11,6 +11,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" capsulev1beta1 "github.com/clastix/capsule/api/v1beta1" ) @@ -33,6 +34,13 @@ var _ = Describe("Deleting a tenant with protected annotation", func() { }, } + JustAfterEach(func() { + Expect(k8sClient.Get(context.TODO(), types.NamespacedName{Name: tnt.GetName()}, tnt)).Should(Succeed()) + tnt.SetAnnotations(map[string]string{}) + Expect(k8sClient.Update(context.TODO(), tnt)).Should(Succeed()) + Expect(k8sClient.Delete(context.TODO(), tnt)).Should(Succeed()) + }) + It("should fail", func() { Expect(k8sClient.Create(context.TODO(), tnt)).Should(Succeed()) Expect(k8sClient.Delete(context.TODO(), tnt)).ShouldNot(Succeed())