@@ -379,12 +379,13 @@ func TestFilterLabels(t *testing.T) {
379
379
}
380
380
381
381
type TC struct {
382
- description string
383
- labelName string
384
- labelValue string
385
- features nfdv1alpha1.Features
386
- expectErr bool
387
- expectedValue string
382
+ description string
383
+ labelName string
384
+ labelValue string
385
+ features nfdv1alpha1.Features
386
+ expectErr bool
387
+ expectedValue string
388
+ expectedAnnotations map [string ]string
388
389
}
389
390
390
391
tcs := []TC {
@@ -459,26 +460,57 @@ func TestFilterLabels(t *testing.T) {
459
460
}
460
461
})
461
462
}
463
+
464
+ tcs = []TC {
465
+ {
466
+ description : "Unprefixed annotation should not be allowed" ,
467
+ expectedAnnotations : map [string ]string {},
468
+ },
469
+ }
470
+
471
+ for _ , tc := range tcs {
472
+ t .Run (tc .description , func (t * testing.T ) {
473
+ prefixlessAnnotation := map [string ]string {
474
+ "test-annotation" : "bar" ,
475
+ }
476
+ filteredAnnotations := fakeMaster .filterFeatureAnnotations (prefixlessAnnotation )
477
+ Convey ("Unprefixed annotation should not be allowed" , t , func () {
478
+ So (filteredAnnotations , ShouldEqual , tc .expectedAnnotations )
479
+ })
480
+ })
481
+ }
482
+
462
483
// Create a new fake master with the feature gate enabled
463
484
fakeMaster = newFakeMasterWithFeatureGate ()
464
485
tcs = []TC {
465
486
{
466
- description : "Unprefixed should be allowed" ,
487
+ description : "Unprefixed label & annotation should be allowed" ,
467
488
labelName : "test-label" ,
468
489
labelValue : "test-value" ,
469
490
expectedValue : "test-value" ,
491
+ expectedAnnotations : map [string ]string {
492
+ "test-annotation" : "bar" ,
493
+ },
470
494
},
471
495
}
472
496
for _ , tc := range tcs {
473
497
t .Run (tc .description , func (t * testing.T ) {
498
+ prefixlessAnnotation := map [string ]string {
499
+ "test-annotation" : "bar" ,
500
+ }
501
+
474
502
labelValue , err := fakeMaster .filterFeatureLabel (tc .labelName , tc .labelValue , & tc .features )
503
+ filteredAnnotations := fakeMaster .filterFeatureAnnotations (prefixlessAnnotation )
475
504
476
505
Convey ("Label should not be filtered out" , t , func () {
477
506
So (err , ShouldBeNil )
478
507
})
479
508
Convey ("Label value should be correct" , t , func () {
480
509
So (labelValue , ShouldEqual , tc .expectedValue )
481
510
})
511
+ Convey ("Unprefixed annotation should be allowed" , t , func () {
512
+ So (filteredAnnotations , ShouldEqual , tc .expectedAnnotations )
513
+ })
482
514
})
483
515
}
484
516
}
0 commit comments