...

Source file src/github.com/openshift/api/config/v1/feature_gates_test.go

Documentation: github.com/openshift/api/config/v1

     1  package v1
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	utilerrors "k8s.io/apimachinery/pkg/util/errors"
     8  )
     9  
    10  func validateFeatureGateDescription(in FeatureGateDescription) error {
    11  	errs := []error{}
    12  
    13  	if len(in.FeatureGateAttributes.Name) == 0 {
    14  		errs = append(errs, fmt.Errorf("must have name"))
    15  	}
    16  	if len(in.OwningJiraComponent) == 0 {
    17  		errs = append(errs, fmt.Errorf("featureGate/%v must have owningJiraComponent", in.FeatureGateAttributes.Name))
    18  	}
    19  	if len(in.ResponsiblePerson) == 0 {
    20  		errs = append(errs, fmt.Errorf("featureGate/%v must have responsiblePerson", in.FeatureGateAttributes.Name))
    21  	}
    22  	if len(in.OwningProduct) == 0 {
    23  		errs = append(errs, fmt.Errorf("featureGate/%v must have owningProduct", in.FeatureGateAttributes.Name))
    24  	}
    25  	if in.OwningProduct != kubernetes && in.OwningProduct != ocpSpecific {
    26  		errs = append(errs, fmt.Errorf("featureGate/%v owningProduct must be either %q or %q", in.FeatureGateAttributes.Name, kubernetes, ocpSpecific))
    27  	}
    28  
    29  	return utilerrors.NewAggregate(errs)
    30  }
    31  
    32  func TestAllFeatureGates(t *testing.T) {
    33  	for featureSet, currFeatures := range FeatureSets {
    34  		for _, enabled := range currFeatures.Enabled {
    35  			for _, disabled := range currFeatures.Disabled {
    36  				if enabled.FeatureGateAttributes.Name == disabled.FeatureGateAttributes.Name {
    37  					t.Errorf("featureSet/%v has featureGate/%v both enabled and disabled", featureSet, enabled.FeatureGateAttributes.Name)
    38  				}
    39  			}
    40  
    41  			if err := validateFeatureGateDescription(enabled); err != nil {
    42  				t.Error(err)
    43  			}
    44  		}
    45  
    46  		for _, disabled := range currFeatures.Disabled {
    47  			if err := validateFeatureGateDescription(disabled); err != nil {
    48  				t.Error(err)
    49  			}
    50  		}
    51  	}
    52  }
    53  

View as plain text