@@ -175,4 +175,78 @@ var _ = Describe("Predicate", func() {
175
175
close (done )
176
176
})
177
177
})
178
+
179
+ Describe ("Default predicate funcs" , func () {
180
+
181
+ defaultFuncs := predicate .DefaultPredicate ()
182
+
183
+ It ("should call defaultCreateFunc" , func () {
184
+ By ("Return true if the create event should be proccessed" )
185
+ passEvt := event.CreateEvent {
186
+ Meta : pod .GetObjectMeta (),
187
+ Object : pod ,
188
+ }
189
+ Expect (defaultFuncs .Create (passEvt )).To (BeTrue ())
190
+
191
+ By ("Return false if the create event should not be proccessed" )
192
+ failEvt1 := event.CreateEvent {Meta : pod .GetObjectMeta ()}
193
+ Expect (defaultFuncs .Create (failEvt1 )).To (BeFalse ())
194
+ failEvt2 := event.CreateEvent {Object : pod }
195
+ Expect (defaultFuncs .Create (failEvt2 )).To (BeFalse ())
196
+ })
197
+
198
+ It ("should call defaultDeleteFunc" , func () {
199
+ By ("Return true if the delete event should be proccessed" )
200
+ passEvt := event.DeleteEvent {
201
+ Meta : pod .GetObjectMeta (),
202
+ Object : pod ,
203
+ }
204
+ Expect (defaultFuncs .Delete (passEvt )).To (BeTrue ())
205
+ By ("Return false if the delete event should not be proccessed" )
206
+ failEvt := event.DeleteEvent {}
207
+ Expect (defaultFuncs .Delete (failEvt )).To (BeFalse ())
208
+
209
+ })
210
+
211
+ It ("should call defaultUpdateFunc" , func () {
212
+ newPod := pod .DeepCopy ()
213
+ newPod .Name = "baz2"
214
+ newPod .Namespace = "biz2"
215
+
216
+ By ("Return true if the update event should be proccessed" )
217
+ passEvt := event.UpdateEvent {
218
+ MetaOld : pod .GetObjectMeta (),
219
+ ObjectOld : pod ,
220
+ MetaNew : newPod .GetObjectMeta (),
221
+ ObjectNew : newPod ,
222
+ }
223
+ Expect (defaultFuncs .Update (passEvt )).To (BeTrue ())
224
+ By ("Return false if the udpate event should not be proccessed" )
225
+ failEvt1 := event.UpdateEvent {}
226
+ failEvt2 := event.UpdateEvent {MetaOld : pod .GetObjectMeta ()}
227
+ failEvt3 := event.UpdateEvent {MetaOld : pod .GetObjectMeta (), ObjectOld : pod }
228
+ failEvt4 := event.UpdateEvent {MetaOld : pod .GetObjectMeta (), ObjectOld : pod , MetaNew : newPod .GetObjectMeta ()}
229
+ failEvt5 := event.UpdateEvent {MetaOld : pod .GetObjectMeta (), ObjectOld : pod , ObjectNew : newPod }
230
+ Expect (defaultFuncs .Update (failEvt1 )).To (BeFalse ())
231
+ Expect (defaultFuncs .Update (failEvt2 )).To (BeFalse ())
232
+ Expect (defaultFuncs .Update (failEvt3 )).To (BeFalse ())
233
+ Expect (defaultFuncs .Update (failEvt4 )).To (BeFalse ())
234
+ Expect (defaultFuncs .Update (failEvt5 )).To (BeFalse ())
235
+ })
236
+
237
+ It ("should call defaultGeneric" , func () {
238
+ By ("Return true if the generic event should be proccessed" )
239
+ passEvt := event.GenericEvent {
240
+ Meta : pod .GetObjectMeta (),
241
+ Object : pod ,
242
+ }
243
+ Expect (defaultFuncs .Generic (passEvt )).To (BeTrue ())
244
+ By ("Return false if the generic event should not be proccessed" )
245
+ failEvt1 := event.GenericEvent {Meta : pod .GetObjectMeta ()}
246
+ Expect (defaultFuncs .Generic (failEvt1 )).To (BeFalse ())
247
+ failEvt2 := event.GenericEvent {Object : pod }
248
+ Expect (defaultFuncs .Generic (failEvt2 )).To (BeFalse ())
249
+ })
250
+ })
251
+
178
252
})
0 commit comments