diff --git a/cmd/cluster/cluster_test.go b/cmd/cluster/cluster_test.go index 79415d862..ccb522ad5 100644 --- a/cmd/cluster/cluster_test.go +++ b/cmd/cluster/cluster_test.go @@ -35,11 +35,6 @@ func TestNewClusterCommand(t *testing.T) { CmdLine: "--help", Cmd: cluster.NewClusterCommand(fakeRootSettings), }, - { - Name: "cluster-init-cmd-with-help", - CmdLine: "--help", - Cmd: cluster.NewInitCommand(fakeRootSettings), - }, } for _, testcase := range tests { testutil.RunTest(t, testcase) diff --git a/cmd/cluster/init_test.go b/cmd/cluster/init_test.go new file mode 100755 index 000000000..a9ee71880 --- /dev/null +++ b/cmd/cluster/init_test.go @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cluster_test + +import ( + "testing" + + "opendev.org/airship/airshipctl/cmd/cluster" + "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/testutil" +) + +func TestNewClusterInitCmd(t *testing.T) { + fakeRootSettings := &environment.AirshipCTLSettings{ + AirshipConfigPath: "../../testdata/k8s/config.yaml", + KubeConfigPath: "../../testdata/k8s/kubeconfig.yaml", + } + fakeRootSettings.InitConfig() + + tests := []*testutil.CmdTest{ + { + Name: "cluster-init-cmd-with-help", + CmdLine: "--help", + Cmd: cluster.NewInitCommand(fakeRootSettings), + }, + } + for _, testcase := range tests { + testutil.RunTest(t, testcase) + } +} diff --git a/cmd/cluster/move_test.go b/cmd/cluster/move_test.go new file mode 100755 index 000000000..0ae160d2d --- /dev/null +++ b/cmd/cluster/move_test.go @@ -0,0 +1,41 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cluster_test + +import ( + "testing" + + "opendev.org/airship/airshipctl/cmd/cluster" + "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/testutil" +) + +func TestNewClusterMoveCmd(t *testing.T) { + fakeRootSettings := &environment.AirshipCTLSettings{ + AirshipConfigPath: "../../testdata/k8s/config.yaml", + KubeConfigPath: "../../testdata/k8s/kubeconfig.yaml", + } + + tests := []*testutil.CmdTest{ + { + Name: "cluster-move-cmd-with-help", + CmdLine: "--help", + Cmd: cluster.NewMoveCommand(fakeRootSettings), + }, + } + for _, testcase := range tests { + testutil.RunTest(t, testcase) + } +} diff --git a/cmd/cluster/status_test.go b/cmd/cluster/status_test.go index 3abb0b290..16af8911b 100644 --- a/cmd/cluster/status_test.go +++ b/cmd/cluster/status_test.go @@ -34,7 +34,7 @@ const ( fixturesPath = "testdata/statusmap" ) -func TestStatusCmd(t *testing.T) { +func TestNewClusterStatusCmd(t *testing.T) { tests := []struct { cmdTest *testutil.CmdTest resources []runtime.Object @@ -46,6 +46,12 @@ func TestStatusCmd(t *testing.T) { CmdLine: "", }, }, + { + cmdTest: &testutil.CmdTest{ + Name: "cluster-status-cmd-with-help", + CmdLine: "--help", + }, + }, { cmdTest: &testutil.CmdTest{ Name: "check-status-with-resources", diff --git a/cmd/cluster/testdata/TestNewClusterCommandGoldenOutput/cluster-init-cmd-with-help.golden b/cmd/cluster/testdata/TestNewClusterInitCmdGoldenOutput/cluster-init-cmd-with-help.golden similarity index 100% rename from cmd/cluster/testdata/TestNewClusterCommandGoldenOutput/cluster-init-cmd-with-help.golden rename to cmd/cluster/testdata/TestNewClusterInitCmdGoldenOutput/cluster-init-cmd-with-help.golden diff --git a/cmd/cluster/testdata/TestNewClusterMoveCmdGoldenOutput/cluster-move-cmd-with-help.golden b/cmd/cluster/testdata/TestNewClusterMoveCmdGoldenOutput/cluster-move-cmd-with-help.golden new file mode 100644 index 000000000..b803f3408 --- /dev/null +++ b/cmd/cluster/testdata/TestNewClusterMoveCmdGoldenOutput/cluster-move-cmd-with-help.golden @@ -0,0 +1,17 @@ +Move Cluster API objects, provider specific objects and all dependencies to the target cluster. + +Note: The destination cluster MUST have the required provider components installed. + +Usage: + move [flags] + +Examples: + +Move Cluster API objects, provider specific objects and all dependencies to the target cluster. + + airshipctl cluster move --target-context <context name> + + +Flags: + -h, --help help for move + --target-context string Context to be used within the kubeconfig file for the target cluster. If empty, current context will be used. diff --git a/cmd/cluster/testdata/TestStatusCmdGoldenOutput/check-status-no-resources.golden b/cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/check-status-no-resources.golden similarity index 100% rename from cmd/cluster/testdata/TestStatusCmdGoldenOutput/check-status-no-resources.golden rename to cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/check-status-no-resources.golden diff --git a/cmd/cluster/testdata/TestStatusCmdGoldenOutput/check-status-with-resources.golden b/cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/check-status-with-resources.golden similarity index 100% rename from cmd/cluster/testdata/TestStatusCmdGoldenOutput/check-status-with-resources.golden rename to cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/check-status-with-resources.golden diff --git a/cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/cluster-status-cmd-with-help.golden b/cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/cluster-status-cmd-with-help.golden new file mode 100644 index 000000000..e02d48fe1 --- /dev/null +++ b/cmd/cluster/testdata/TestNewClusterStatusCmdGoldenOutput/cluster-status-cmd-with-help.golden @@ -0,0 +1,7 @@ +Retrieve statuses of deployed cluster components + +Usage: + status [flags] + +Flags: + -h, --help help for status