@@ -386,6 +386,7 @@ func TestFilterLabels(t *testing.T) {
386386 expectErr bool
387387 expectedValue string
388388 expectedExtResources ExtendedResources
389+ expectedAnnotations map [string ]string
389390 }
390391
391392 tcs := []TC {
@@ -463,41 +464,64 @@ func TestFilterLabels(t *testing.T) {
463464
464465 tcs = []TC {
465466 {
466- description : "Unprefixed extended resources should not be allowed" ,
467+ description : "Unprefixed extended resources & annotations should not be allowed" ,
467468 expectedExtResources : ExtendedResources {},
469+ expectedAnnotations : map [string ]string {},
468470 },
469471 }
470472
471473 extendedResources := ExtendedResources {"micromicrowaves" : "10" , "tooster" : "5" }
474+ prefixlessAnnotation := map [string ]string {"test-annotation" : "bar" }
475+
472476 for _ , tc := range tcs {
473477 t .Run (tc .description , func (t * testing.T ) {
474478 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 () {
476480 So (outExtendedResources , ShouldEqual , tc .expectedExtResources )
477481 })
478482 })
479483 }
480484
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+
481494 // Create a new fake master with the feature gate enabled
482495 fakeMaster = newFakeMasterWithFeatureGate ()
483496 tcs = []TC {
484497 {
485- description : "Unprefixed should be allowed" ,
498+ description : "Unprefixed label & annotation should be allowed" ,
486499 labelName : "test-label" ,
487500 labelValue : "test-value" ,
488501 expectedValue : "test-value" ,
502+ expectedAnnotations : map [string ]string {
503+ "test-annotation" : "bar" ,
504+ },
489505 },
490506 }
491507 for _ , tc := range tcs {
492508 t .Run (tc .description , func (t * testing.T ) {
509+ testPrefixlessAnnotation := map [string ]string {
510+ "test-annotation" : "bar" ,
511+ }
512+
493513 labelValue , err := fakeMaster .filterFeatureLabel (tc .labelName , tc .labelValue , & tc .features )
514+ filteredAnnotations := fakeMaster .filterFeatureAnnotations (testPrefixlessAnnotation )
494515
495516 Convey ("Label should not be filtered out" , t , func () {
496517 So (err , ShouldBeNil )
497518 })
498519 Convey ("Label value should be correct" , t , func () {
499520 So (labelValue , ShouldEqual , tc .expectedValue )
500521 })
522+ Convey ("Unprefixed annotation should be allowed" , t , func () {
523+ So (filteredAnnotations , ShouldEqual , tc .expectedAnnotations )
524+ })
501525 })
502526 }
503527
0 commit comments