diff --git a/pkg/controllers/externalsecret/externalsecret_controller_test.go b/pkg/controllers/externalsecret/externalsecret_controller_test.go index cb05429c0..1d5a36b3c 100644 --- a/pkg/controllers/externalsecret/externalsecret_controller_test.go +++ b/pkg/controllers/externalsecret/externalsecret_controller_test.go @@ -904,6 +904,43 @@ var _ = Describe("ExternalSecret refresh logic", func() { }) }) +var _ = Describe("Controller Reconcile logic", func() { + Context("controller reconcile", func() { + It("should reconcile when resource is not synced", func() { + Expect(shouldReconcile(esv1alpha1.ExternalSecret{ + Status: esv1alpha1.ExternalSecretStatus{ + SyncedResourceVersion: "some resource version", + Conditions: []esv1alpha1.ExternalSecretStatusCondition{{Reason: "NotASecretSynced"}}, + }, + })).To(BeTrue()) + }) + + It("should reconcile when secret isn't immutable", func() { + Expect(shouldReconcile(esv1alpha1.ExternalSecret{ + Spec: esv1alpha1.ExternalSecretSpec{ + Target: esv1alpha1.ExternalSecretTarget{ + Immutable: false, + }, + }, + })).To(BeTrue()) + }) + + It("should not reconcile if secret is immutable and has synced condition", func() { + Expect(shouldReconcile(esv1alpha1.ExternalSecret{ + Spec: esv1alpha1.ExternalSecretSpec{ + Target: esv1alpha1.ExternalSecretTarget{ + Immutable: true, + }, + }, + Status: esv1alpha1.ExternalSecretStatus{ + SyncedResourceVersion: "some resource version", + Conditions: []esv1alpha1.ExternalSecretStatusCondition{{Reason: "SecretSynced"}}, + }, + })).To(BeFalse()) + }) + }) +}) + // CreateNamespace creates a new namespace in the cluster. func CreateNamespace(baseName string, c client.Client) (string, error) { genName := fmt.Sprintf("ctrl-test-%v", baseName)