From 07415bdabfeb86cff8210608f9bb93cf17bff134 Mon Sep 17 00:00:00 2001 From: Marc Ingram Date: Fri, 21 Jan 2022 14:01:45 -0700 Subject: [PATCH] improve test? --- .../externalsecret_controller_test.go | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/controllers/externalsecret/externalsecret_controller_test.go b/pkg/controllers/externalsecret/externalsecret_controller_test.go index f9fb5d30a..3747aef8a 100644 --- a/pkg/controllers/externalsecret/externalsecret_controller_test.go +++ b/pkg/controllers/externalsecret/externalsecret_controller_test.go @@ -336,7 +336,26 @@ var _ = Describe("ExternalSecret controller", func() { }, client.FieldOwner(FakeManager))).To(Succeed()) tc.checkSecret = func(es *esv1alpha1.ExternalSecret, secret *v1.Secret) { - Expect(secret.ResourceVersion).To(Equal("295")) + oldResourceVersion := secret.ResourceVersion + + cleanSecret := secret.DeepCopy() + Expect(k8sClient.Patch(context.Background(), secret, client.MergeFrom(cleanSecret))).To(Succeed()) + + newSecret := &v1.Secret{} + + Eventually(func() bool { + secretLookupKey := types.NamespacedName{ + Name: ExternalSecretTargetSecretName, + Namespace: ExternalSecretNamespace, + } + + err := k8sClient.Get(context.Background(), secretLookupKey, newSecret) + if err != nil { + return false + } + return oldResourceVersion == newSecret.ResourceVersion + }, timeout, interval).Should(Equal(true)) + } }