@@ -386,6 +386,7 @@ func TestFilterLabels(t *testing.T) {
386
386
expectErr bool
387
387
expectedValue string
388
388
expectedExtResources ExtendedResources
389
+ expectedAnnotations map [string ]string
389
390
}
390
391
391
392
tcs := []TC {
@@ -463,41 +464,64 @@ func TestFilterLabels(t *testing.T) {
463
464
464
465
tcs = []TC {
465
466
{
466
- description : "Unprefixed extended resources should not be allowed" ,
467
+ description : "Unprefixed extended resources & annotations should not be allowed" ,
467
468
expectedExtResources : ExtendedResources {},
469
+ expectedAnnotations : map [string ]string {},
468
470
},
469
471
}
470
472
471
473
extendedResources := ExtendedResources {"micromicrowaves" : "10" , "tooster" : "5" }
474
+ prefixlessAnnotation := map [string ]string {"test-annotation" : "bar" }
475
+
472
476
for _ , tc := range tcs {
473
477
t .Run (tc .description , func (t * testing.T ) {
474
478
outExtendedResources := fakeMaster .filterExtendedResources (& tc .features , extendedResources )
475
- Convey ("Unprefixed extended resources should npotbe allowed" , t , func () {
479
+ Convey ("Unprefixed extended resources should not be allowed" , t , func () {
476
480
So (outExtendedResources , ShouldEqual , tc .expectedExtResources )
477
481
})
478
482
})
479
483
}
480
484
485
+ for _ , tc := range tcs {
486
+ t .Run (tc .description , func (t * testing.T ) {
487
+ filteredAnnotations := fakeMaster .filterFeatureAnnotations (prefixlessAnnotation )
488
+ Convey ("Unprefixed annotation should not be allowed" , t , func () {
489
+ So (filteredAnnotations , ShouldEqual , tc .expectedAnnotations )
490
+ })
491
+ })
492
+ }
493
+
481
494
// Create a new fake master with the feature gate enabled
482
495
fakeMaster = newFakeMasterWithFeatureGate ()
483
496
tcs = []TC {
484
497
{
485
- description : "Unprefixed should be allowed" ,
498
+ description : "Unprefixed label & annotation should be allowed" ,
486
499
labelName : "test-label" ,
487
500
labelValue : "test-value" ,
488
501
expectedValue : "test-value" ,
502
+ expectedAnnotations : map [string ]string {
503
+ "test-annotation" : "bar" ,
504
+ },
489
505
},
490
506
}
491
507
for _ , tc := range tcs {
492
508
t .Run (tc .description , func (t * testing.T ) {
509
+ testPrefixlessAnnotation := map [string ]string {
510
+ "test-annotation" : "bar" ,
511
+ }
512
+
493
513
labelValue , err := fakeMaster .filterFeatureLabel (tc .labelName , tc .labelValue , & tc .features )
514
+ filteredAnnotations := fakeMaster .filterFeatureAnnotations (testPrefixlessAnnotation )
494
515
495
516
Convey ("Label should not be filtered out" , t , func () {
496
517
So (err , ShouldBeNil )
497
518
})
498
519
Convey ("Label value should be correct" , t , func () {
499
520
So (labelValue , ShouldEqual , tc .expectedValue )
500
521
})
522
+ Convey ("Unprefixed annotation should be allowed" , t , func () {
523
+ So (filteredAnnotations , ShouldEqual , tc .expectedAnnotations )
524
+ })
501
525
})
502
526
}
503
527
0 commit comments