@@ -18,6 +18,7 @@ package v3
18
18
19
19
import (
20
20
"errors"
21
+ "sort"
21
22
"testing"
22
23
23
24
. "github.com/onsi/ginkgo"
@@ -302,42 +303,60 @@ var _ = Describe("cfg", func() {
302
303
Expect (c .HasGroup ("other-group" )).To (BeFalse ())
303
304
})
304
305
305
- It ("IsCRDVersionCompatible should return true with no tracked resources" , func () {
306
- Expect (c .IsCRDVersionCompatible ("v1beta1" )).To (BeTrue ())
307
- Expect (c .IsCRDVersionCompatible ("v1" )).To (BeTrue ())
306
+ It ("ListCRDVersions should return an empty list with no tracked resources" , func () {
307
+ Expect (c .ListCRDVersions ()).To (BeEmpty ())
308
308
})
309
309
310
- It ("IsCRDVersionCompatible should return true only for matching CRD versions of tracked resources" , func () {
311
- c .Resources = append (c .Resources , resource.Resource {
312
- GVK : resource.GVK {
313
- Group : res .Group ,
314
- Version : res .Version ,
315
- Kind : res .Kind ,
310
+ It ("ListCRDVersions should return a list of tracked resources CRD versions" , func () {
311
+ c .Resources = append (c .Resources ,
312
+ resource.Resource {
313
+ GVK : resource.GVK {
314
+ Group : res .Group ,
315
+ Version : res .Version ,
316
+ Kind : res .Kind ,
317
+ },
318
+ API : & resource.API {CRDVersion : "v1beta1" },
319
+ },
320
+ resource.Resource {
321
+ GVK : resource.GVK {
322
+ Group : res .Group ,
323
+ Version : res .Version ,
324
+ Kind : "OtherKind" ,
325
+ },
326
+ API : & resource.API {CRDVersion : "v1" },
316
327
},
317
- API : & resource.API {CRDVersion : "v1beta1" },
318
- })
319
- Expect (c .IsCRDVersionCompatible ("v1beta1" )).To (BeTrue ())
320
- Expect (c .IsCRDVersionCompatible ("v1" )).To (BeFalse ())
321
- Expect (c .IsCRDVersionCompatible ("v2" )).To (BeFalse ())
328
+ )
329
+ versions := c .ListCRDVersions ()
330
+ sort .Strings (versions ) // ListCRDVersions has no order guarantee so sorting for reproducibility
331
+ Expect (versions ).To (Equal ([]string {"v1" , "v1beta1" }))
322
332
})
323
333
324
- It ("IsWebhookVersionCompatible should return true with no tracked resources" , func () {
325
- Expect (c .IsWebhookVersionCompatible ("v1beta1" )).To (BeTrue ())
326
- Expect (c .IsWebhookVersionCompatible ("v1" )).To (BeTrue ())
334
+ It ("ListWebhookVersions should return an empty list with no tracked resources" , func () {
335
+ Expect (c .ListWebhookVersions ()).To (BeEmpty ())
327
336
})
328
337
329
- It ("IsWebhookVersionCompatible should return true only for matching webhook versions of tracked resources" , func () {
330
- c .Resources = append (c .Resources , resource.Resource {
331
- GVK : resource.GVK {
332
- Group : res .Group ,
333
- Version : res .Version ,
334
- Kind : res .Kind ,
338
+ It ("ListWebhookVersions should return a list of tracked resources webhook versions" , func () {
339
+ c .Resources = append (c .Resources ,
340
+ resource.Resource {
341
+ GVK : resource.GVK {
342
+ Group : res .Group ,
343
+ Version : res .Version ,
344
+ Kind : res .Kind ,
345
+ },
346
+ Webhooks : & resource.Webhooks {WebhookVersion : "v1beta1" },
347
+ },
348
+ resource.Resource {
349
+ GVK : resource.GVK {
350
+ Group : res .Group ,
351
+ Version : res .Version ,
352
+ Kind : "OtherKind" ,
353
+ },
354
+ Webhooks : & resource.Webhooks {WebhookVersion : "v1" },
335
355
},
336
- Webhooks : & resource.Webhooks {WebhookVersion : "v1beta1" },
337
- })
338
- Expect (c .IsWebhookVersionCompatible ("v1beta1" )).To (BeTrue ())
339
- Expect (c .IsWebhookVersionCompatible ("v1" )).To (BeFalse ())
340
- Expect (c .IsWebhookVersionCompatible ("v2" )).To (BeFalse ())
356
+ )
357
+ versions := c .ListWebhookVersions ()
358
+ sort .Strings (versions ) // ListWebhookVersions has no order guarantee so sorting for reproducibility
359
+ Expect (versions ).To (Equal ([]string {"v1" , "v1beta1" }))
341
360
})
342
361
})
343
362
0 commit comments