Add more unit tests for UpdateOnConfigChange
@@ -24,6 +24,9 @@ var _ = Describe("GetReconciles", func() {
manager *cfakes.FakeManager
configMap1 corev1.ConfigMap
+ configMap2 corev1.ConfigMap
+ secret1 corev1.Secret
+ secret2 corev1.Secret
env testing.Catalog
client client.Client
)
@@ -35,12 +38,18 @@ var _ = Describe("GetReconciles", func() {
ests = env.OwnedReferencesExtendedStatefulSet("foo")
configMap1 = env.DefaultConfigMap("example1")
+ configMap2 = env.DefaultConfigMap("example2")
+ secret1 = env.DefaultSecret("example1")
+ secret2 = env.DefaultSecret("example2")
})
JustBeforeEach(func() {
client = fake.NewFakeClient(
&ests,
&configMap1,
+ &configMap2,
+ &secret1,
+ &secret2,
)
})
@@ -49,11 +58,29 @@ var _ = Describe("GetReconciles", func() {
ests.Spec.UpdateOnConfigChange = true
})
- It("triggers a reconcile when a config changes", func() {
+ It("triggers a reconcile when a ConfigRef changes", func() {
requests, err := reference.GetReconciles(context.Background(), client, reference.ReconcileForExtendedStatefulSet, &configMap1)
Expect(err).ToNot(HaveOccurred())
Expect(len(requests)).To(Equal(1))
})
+
+ It("triggers a reconcile when a ConfigKeyRef changes", func() {
+ requests, err := reference.GetReconciles(context.Background(), client, reference.ReconcileForExtendedStatefulSet, &configMap2)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(requests)).To(Equal(1))
+ })
+
+ It("triggers a reconcile when a SecretRef changes", func() {
+ requests, err := reference.GetReconciles(context.Background(), client, reference.ReconcileForExtendedStatefulSet, &secret1)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(requests)).To(Equal(1))
+ })
+
+ It("triggers a reconcile when a SecretKeyRef changes", func() {
+ requests, err := reference.GetReconciles(context.Background(), client, reference.ReconcileForExtendedStatefulSet, &secret2)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(requests)).To(Equal(1))
+ })
})
Context("when UpdateOnConfigChange is false", func() {
@@ -61,7 +88,7 @@ var _ = Describe("GetReconciles", func() {
ests.Spec.UpdateOnConfigChange = false
})
- It("doesn't trigger a reconcile when a config changes", func() {
+ It("doesn't trigger a reconcile when a referenced configmap changes", func() {
requests, err := reference.GetReconciles(context.Background(), client, reference.ReconcileForExtendedStatefulSet, &configMap1)
Expect(err).ToNot(HaveOccurred())
Expect(len(requests)).To(Equal(0))
