add unit test for feature gate supports

pull/6112/head
Medya Gh 2019-12-20 01:17:33 -08:00
parent 1014a57ea8
commit f39ba0deb0
3 changed files with 31 additions and 4 deletions

View File

@ -223,6 +223,7 @@ func (d *Driver) Start() error {
}
return nil
}
// TODO:medyagh maybe make it idempotent
return fmt.Errorf("cant start a not-stopped (%s) kic node", s)
}

View File

@ -26,9 +26,8 @@ import (
"k8s.io/kubernetes/cmd/kubeadm/app/features"
)
// supports indicates whether a feature name is supported on the
// feature gates for kubeadm
func supports(featureName string) bool {
// supportedFG indicates whether a feature name is supported by the bootstrapper
func supportedFG(featureName string) bool {
for k := range features.InitFeatureGates {
if featureName == k {
return true
@ -54,7 +53,7 @@ func parseFeatureArgs(featureGates string) (map[string]bool, string, error) {
k := strings.TrimSpace(fg[0])
v := strings.TrimSpace(fg[1])
if !supports(k) {
if !supportedFG(k) {
componentFeatureArgs = fmt.Sprintf("%s%s,", componentFeatureArgs, s)
continue
}

View File

@ -65,3 +65,30 @@ func TestParseFeatureArgs(t *testing.T) {
})
}
}
func TestSupport(t *testing.T) {
tests := []struct {
name string
expected bool
}{
{
name: "CoreDNS",
expected: true,
},
{
name: "Life is Beautiful !",
expected: false,
},
{
name: "",
expected: false,
},
}
for _, tc := range tests {
if supportedFG(tc.name) != tc.expected {
t.Errorf("expected supportedFG(%s) to be %t ! ", tc.name, tc.expected)
}
}
}