github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/pkg/install/kube_scheduler_options_test.go (about)

     1  package install
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  	"testing"
     7  )
     8  
     9  func TestValidateKubeSchedulerOptions(t *testing.T) {
    10  	tests := []struct {
    11  		opts            KubeSchedulerOptions
    12  		valid           bool
    13  		protectedFields []string
    14  	}{
    15  		{
    16  			opts:  KubeSchedulerOptions{},
    17  			valid: true,
    18  		},
    19  		{
    20  			opts: KubeSchedulerOptions{
    21  				Overrides: map[string]string{
    22  					"foobar": "baz",
    23  				},
    24  			},
    25  			valid: true,
    26  		},
    27  		{
    28  			opts: KubeSchedulerOptions{
    29  				Overrides: map[string]string{
    30  					"kubeconfig": "/foo/.kube/config",
    31  				},
    32  			},
    33  			valid:           false,
    34  			protectedFields: []string{"kubeconfig"},
    35  		},
    36  		{
    37  			opts: KubeSchedulerOptions{
    38  				Overrides: map[string]string{
    39  					"kubeconfig": "/foo/.kube/config",
    40  					"v":          "3",
    41  				},
    42  			},
    43  			valid:           false,
    44  			protectedFields: []string{"kubeconfig"},
    45  		},
    46  	}
    47  	for _, test := range tests {
    48  		ok, err := test.opts.validate()
    49  		assertEqual(t, ok, test.valid)
    50  		if !test.valid {
    51  			assertEqual(t, err, []error{fmt.Errorf("Kube Scheduler Option(s) [%v] cannot be overridden", strings.Join(test.protectedFields, ", "))})
    52  		}
    53  	}
    54  }