1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

add tests for controller reconciling logic

This commit is contained in:
Arthur 2021-10-06 21:23:41 -03:00
parent 4de31e9d4d
commit 1f5978eb13

View file

@ -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)