@@ -516,4 +516,35 @@ var _ = Describe("Predicate", func() {
516
516
})
517
517
})
518
518
})
519
+
520
+ Describe ("When checking a LabelSelectorPredicate" , func () {
521
+ instance , err := predicate .LabelSelectorPredicate (metav1.LabelSelector {MatchLabels : map [string ]string {"foo" : "bar" }})
522
+ if err != nil {
523
+ Fail ("Improper Label Selector passed during predicate instantiation." )
524
+ }
525
+
526
+ Context ("When the Selector does not match the event labels" , func () {
527
+ It ("should return false" , func () {
528
+ failMatch := & corev1.Pod {}
529
+ Expect (instance .Create (event.CreateEvent {Object : failMatch })).To (BeFalse ())
530
+ Expect (instance .Delete (event.DeleteEvent {Object : failMatch })).To (BeFalse ())
531
+ Expect (instance .Generic (event.GenericEvent {Object : failMatch })).To (BeFalse ())
532
+ Expect (instance .Update (event.UpdateEvent {ObjectNew : failMatch })).To (BeFalse ())
533
+ })
534
+ })
535
+
536
+ Context ("When the Selector matches the event labels" , func () {
537
+ It ("should return true" , func () {
538
+ successMatch := & corev1.Pod {
539
+ ObjectMeta : metav1.ObjectMeta {
540
+ Labels : map [string ]string {"foo" : "bar" },
541
+ },
542
+ }
543
+ Expect (instance .Create (event.CreateEvent {Object : successMatch })).To (BeTrue ())
544
+ Expect (instance .Delete (event.DeleteEvent {Object : successMatch })).To (BeTrue ())
545
+ Expect (instance .Generic (event.GenericEvent {Object : successMatch })).To (BeTrue ())
546
+ Expect (instance .Update (event.UpdateEvent {ObjectNew : successMatch })).To (BeTrue ())
547
+ })
548
+ })
549
+ })
519
550
})
0 commit comments