@@ -237,6 +237,19 @@ var _ = Describe("MatchingLabels", func() {
237
237
expectedErrMsg := `values[0][k]: Invalid value: "axahm2EJ8Phiephe2eixohbee9eGeiyees1thuozi1xoh0GiuH3diewi8iem7Nui": must be no more than 63 characters`
238
238
Expect (err .Error ()).To (Equal (expectedErrMsg ))
239
239
})
240
+
241
+ It ("Should add matchingLabels to existing selector" , func () {
242
+ listOpts := & client.ListOptions {}
243
+
244
+ matchingLabels := client .MatchingLabels (map [string ]string {"k" : "v" })
245
+ matchingLabels2 := client .MatchingLabels (map [string ]string {"k2" : "v2" })
246
+
247
+ matchingLabels .ApplyToList (listOpts )
248
+ Expect (listOpts .LabelSelector .String ()).To (Equal ("k=v" ))
249
+
250
+ matchingLabels2 .ApplyToList (listOpts )
251
+ Expect (listOpts .LabelSelector .String ()).To (Equal ("k=v,k2=v2" ))
252
+ })
240
253
})
241
254
242
255
var _ = Describe ("FieldOwner" , func () {
@@ -292,3 +305,35 @@ var _ = Describe("ForceOwnership", func() {
292
305
Expect (* o .Force ).To (Equal (true ))
293
306
})
294
307
})
308
+
309
+ var _ = Describe ("HasLabels" , func () {
310
+ It ("Should produce hasLabels in given order" , func () {
311
+ listOpts := & client.ListOptions {}
312
+
313
+ hasLabels := client .HasLabels ([]string {"labelApe" , "labelFox" })
314
+ hasLabels .ApplyToList (listOpts )
315
+ Expect (listOpts .LabelSelector .String ()).To (Equal ("labelApe,labelFox" ))
316
+ })
317
+
318
+ It ("Should add hasLabels to existing hasLabels selector" , func () {
319
+ listOpts := & client.ListOptions {}
320
+
321
+ hasLabel := client .HasLabels ([]string {"labelApe" })
322
+ hasLabel .ApplyToList (listOpts )
323
+
324
+ hasOtherLabel := client .HasLabels ([]string {"labelFox" })
325
+ hasOtherLabel .ApplyToList (listOpts )
326
+ Expect (listOpts .LabelSelector .String ()).To (Equal ("labelApe,labelFox" ))
327
+ })
328
+
329
+ It ("Should add hasLabels to existing matchingLabels" , func () {
330
+ listOpts := & client.ListOptions {}
331
+
332
+ matchingLabels := client .MatchingLabels (map [string ]string {"k" : "v" })
333
+ matchingLabels .ApplyToList (listOpts )
334
+
335
+ hasLabel := client .HasLabels ([]string {"labelApe" })
336
+ hasLabel .ApplyToList (listOpts )
337
+ Expect (listOpts .LabelSelector .String ()).To (Equal ("k=v,labelApe" ))
338
+ })
339
+ })
0 commit comments