@@ -80,8 +80,8 @@ var _ = Describe("Application Reconciler", func() {
8080 objs = append (objs , service )
8181 objs = append (objs , statefulSet )
8282 objs = append (objs , createPod (labelSet2 , namespace2 ))
83- objs = append (objs , createDaemonSet (labelSet2 , namespace2 ))
84- objs = append (objs , createReplicaSet (labelSet2 , namespace2 ))
83+ objs = append (objs , createDaemonSet (labelSet1 , namespace2 ))
84+ objs = append (objs , createReplicaSet (labelSet1 , namespace2 ))
8585 objs = append (objs , CreatePersistentVolumeClaim (labelSet2 , namespace2 ))
8686 objs = append (objs , createPodDisruptionBudget (labelSet2 , namespace2 ))
8787
@@ -135,10 +135,26 @@ var _ = Describe("Application Reconciler", func() {
135135 Expect (len (ns1List )).To (Equal (3 ))
136136 Expect (componentKinds (ns1List )).To (ConsistOf ("StatefulSet" , "Deployment" , "Service" ))
137137
138- ns2List := applicationReconciler .fetchComponentListResources (ctx , groupKinds , metav1 .SetAsLabelSelector (labelSet2 ), namespace2 , & errs )
138+ ns2l1List := applicationReconciler .fetchComponentListResources (ctx , groupKinds , metav1 .SetAsLabelSelector (labelSet1 ), namespace2 , & errs )
139139 Expect (errs ).To (BeNil ())
140- Expect (len (ns2List )).To (Equal (5 ))
141- Expect (componentKinds (ns2List )).To (ConsistOf ("ReplicaSet" , "DaemonSet" , "PersistentVolumeClaim" , "Pod" , "PodDisruptionBudget" ))
140+ Expect (len (ns2l1List )).To (Equal (2 ))
141+ Expect (componentKinds (ns2l1List )).To (ConsistOf ("ReplicaSet" , "DaemonSet" ))
142+
143+ ns2l2List := applicationReconciler .fetchComponentListResources (ctx , groupKinds , metav1 .SetAsLabelSelector (labelSet2 ), namespace2 , & errs )
144+ Expect (errs ).To (BeNil ())
145+ Expect (len (ns2l2List )).To (Equal (3 ))
146+ Expect (componentKinds (ns2l2List )).To (ConsistOf ("PersistentVolumeClaim" , "Pod" , "PodDisruptionBudget" ))
147+
148+ // Empty selector will select ALL resources in the namespace
149+ ns2AllList := applicationReconciler .fetchComponentListResources (ctx , groupKinds , metav1 .SetAsLabelSelector (map [string ]string {}), namespace2 , & errs )
150+ Expect (errs ).To (BeNil ())
151+ Expect (len (ns2AllList )).To (Equal (5 ))
152+ Expect (componentKinds (ns2AllList )).To (ConsistOf ("ReplicaSet" , "DaemonSet" , "PersistentVolumeClaim" , "Pod" , "PodDisruptionBudget" ))
153+
154+ // No selector will select NO resources in the namespace
155+ ns2NoList := applicationReconciler .fetchComponentListResources (ctx , groupKinds , nil , namespace2 , & errs )
156+ Expect (errs ).To (BeNil ())
157+ Expect (ns2NoList ).To (BeNil ())
142158
143159 })
144160
0 commit comments