Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: test-cmd: init{config, version, api-port} #41275

Merged
merged 1 commit into from
Feb 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 85 additions & 0 deletions cmd/kubeadm/test/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,88 @@ func TestCmdInitToken(t *testing.T) {
kubeadmReset()
}
}

func TestCmdInitKubernetesVersion(t *testing.T) {
if *kubeadmCmdSkip {
t.Log("kubeadm cmd tests being skipped")
t.Skip()
}

var initTest = []struct {
args string
expected bool
}{
{"--use-kubernetes-version=foobar", false},
}

for _, rt := range initTest {
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
if (actual == nil) != rt.expected {
t.Errorf(
"failed CmdInitKubernetesVersion running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
rt.args,
actual,
rt.expected,
(actual == nil),
)
}
kubeadmReset()
}
}

func TestCmdInitConfig(t *testing.T) {
if *kubeadmCmdSkip {
t.Log("kubeadm cmd tests being skipped")
t.Skip()
}

var initTest = []struct {
args string
expected bool
}{
{"--config=foobar", false},
{"--config=/does/not/exist/foo/bar", false},
}

for _, rt := range initTest {
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
if (actual == nil) != rt.expected {
t.Errorf(
"failed CmdInitConfig running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
rt.args,
actual,
rt.expected,
(actual == nil),
)
}
kubeadmReset()
}
}

func TestCmdInitAPIPort(t *testing.T) {
if *kubeadmCmdSkip {
t.Log("kubeadm cmd tests being skipped")
t.Skip()
}

var initTest = []struct {
args string
expected bool
}{
{"--api-port=foobar", false},
}

for _, rt := range initTest {
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
if (actual == nil) != rt.expected {
t.Errorf(
"failed CmdInitAPIPort running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
rt.args,
actual,
rt.expected,
(actual == nil),
)
}
kubeadmReset()
}
}