diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate_test.go index 4636b66b06d..c1306f1fa44 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate_test.go @@ -24,7 +24,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -711,10 +710,3 @@ func TestAnnotateMultipleObjects(t *testing.T) { t.Fatalf("unexpected error: %v", err) } } - -func TestCompletionAnnotateOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdAnnotate("kubectl", tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_edit_last_applied_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_edit_last_applied_test.go deleted file mode 100644 index e6b17629d3b..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_edit_last_applied_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 apply - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionApplyEditLastAppliedOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdApplyEditLastApplied(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_view_last_applied_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_view_last_applied_test.go deleted file mode 100644 index e331acf0929..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply_view_last_applied_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 apply - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionApplyViewLastAppliedOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdApplyViewLastApplied(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/attach/attach_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/attach/attach_test.go index 6f02f5ad121..c9b809a441a 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/attach/attach_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/attach/attach_test.go @@ -26,7 +26,6 @@ import ( "testing" "time" - "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -448,13 +447,6 @@ func TestAttachWarnings(t *testing.T) { } } -func TestCompletionAttachNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdAttach(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - func attachPod() *corev1.Pod { return &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "test", ResourceVersion: "10"}, diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/autoscale/autoscale_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/autoscale/autoscale_test.go deleted file mode 100644 index e68e8321fbf..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/autoscale/autoscale_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 autoscale - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionAutoscaleNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdAutoscale(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "replicationcontroller", "replicaset", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionAutoscaleOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdAutoscale(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_cluster_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_cluster_test.go index 52149cfc2b6..3becba3fdf6 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_cluster_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_cluster_test.go @@ -24,10 +24,8 @@ import ( "reflect" "testing" - "github.com/spf13/cobra" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" ) type deleteClusterTest struct { @@ -97,18 +95,3 @@ func (test deleteClusterTest) run(t *testing.T) { t.Errorf("expected clusters %v, but found %v in kubeconfig", test.expectedClusters, clusters) } } - -func TestCompletionDeleteClusterNoArg(t *testing.T) { - // FIXME - t.Skip("Should not be skipeed") - - pathOptions, streams, factory := cmdtesting.PrepareConfigForCompletion(t) - configCmd := NewCmdConfig(factory, pathOptions, streams) - cmd, _, err := configCmd.Find([]string{"delete-cluster"}) - if err != nil { - t.Fatalf("unexpected error finding delete-cluster command: %v", err) - } - - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "my") - cmdtesting.CheckCompletion(t, comps, []string{"my-cluster"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_context_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_context_test.go index 2d5de6af1d4..04bbe17cbb0 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_context_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/config/delete_context_test.go @@ -24,10 +24,8 @@ import ( "reflect" "testing" - "github.com/spf13/cobra" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" ) type deleteContextTest struct { @@ -98,18 +96,3 @@ func (test deleteContextTest) run(t *testing.T) { t.Errorf("expected contexts %v, but found %v in kubeconfig", test.expectedContexts, contexts) } } - -func TestCompletionDeleteContextNoArg(t *testing.T) { - // FIXME - t.Skip("Should not be skipeed") - - pathOptions, streams, factory := cmdtesting.PrepareConfigForCompletion(t) - configCmd := NewCmdConfig(factory, pathOptions, streams) - cmd, _, err := configCmd.Find([]string{"delete-context"}) - if err != nil { - t.Fatalf("unexpected error finding delete-context command: %v", err) - } - - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "my") - cmdtesting.CheckCompletion(t, comps, []string{"my-context"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/config/rename_context_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/config/rename_context_test.go index ed3758e45a5..cfacb90102a 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/config/rename_context_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/config/rename_context_test.go @@ -24,10 +24,8 @@ import ( "strings" "testing" - "github.com/spf13/cobra" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" ) const ( @@ -156,18 +154,3 @@ func (test renameContextTest) run(t *testing.T) { } } } - -func TestCompletionRenameContextNoArg(t *testing.T) { - // FIXME - t.Skip("Should not be skipeed") - - pathOptions, streams, factory := cmdtesting.PrepareConfigForCompletion(t) - configCmd := NewCmdConfig(factory, pathOptions, streams) - cmd, _, err := configCmd.Find([]string{"rename-context"}) - if err != nil { - t.Fatalf("unexpected error finding rename-context command: %v", err) - } - - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "my") - cmdtesting.CheckCompletion(t, comps, []string{"my-context"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/config/use_context_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/config/use_context_test.go index 59488a13d4f..74424bc51b9 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/config/use_context_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/config/use_context_test.go @@ -22,10 +22,8 @@ import ( "os" "testing" - "github.com/spf13/cobra" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" ) type useContextTest struct { @@ -104,18 +102,3 @@ func (test useContextTest) run(t *testing.T) { t.Errorf("Failed in :%q\n expected config %v, but found %v\n in kubeconfig\n", test.description, test.expectedConfig, config) } } - -func TestCompletionUseContextNoArg(t *testing.T) { - // FIXME - t.Skip("Should not be skipeed") - - pathOptions, streams, factory := cmdtesting.PrepareConfigForCompletion(t) - configCmd := NewCmdConfig(factory, pathOptions, streams) - cmd, _, err := configCmd.Find([]string{"use-context"}) - if err != nil { - t.Fatalf("unexpected error finding use-context command: %v", err) - } - - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "my") - cmdtesting.CheckCompletion(t, comps, []string{"my-context"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/delete/delete_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/delete/delete_test.go index e2781d03605..dbe94cad3e7 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/delete/delete_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/delete/delete_test.go @@ -832,18 +832,3 @@ func TestResourceErrors(t *testing.T) { }) } } - -// TODO -// func TestCompletionDeleteNoArg(t *testing.T) { -// tf, streams := cmdtesting.PreparePodsForCompletion(t) -// cmd := NewCmdDelete(tf, streams) -// comps, directive := cmd.ValidArgsFunction(cmd, []string{""}, "po") -// cmdtesting.CheckCompletionOfResources(t, comps, directive) -// } - -func TestCompletionDeleteOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdDelete(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/describe/describe_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/describe/describe_test.go index c942bc1073a..b6fbfc444ba 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/describe/describe_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/describe/describe_test.go @@ -22,7 +22,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" @@ -324,13 +323,6 @@ func TestDescribeNoResourcesFound(t *testing.T) { } } -func TestCompletionDescribeOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdDescribe("kubectl", tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - type testDescriber struct { Name, Namespace string Settings describe.DescriberSettings diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/drain/drain_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/drain/drain_test.go index 5569cc98a22..eacef7fd300 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/drain/drain_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/drain/drain_test.go @@ -930,27 +930,6 @@ func TestDrain(t *testing.T) { } } -func TestCompletionCordonNoArg(t *testing.T) { - tf, streams := cmdtesting.PrepareNodesForCompletion(t) - cmd := NewCmdCordon(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "f") - cmdtesting.CheckCompletion(t, comps, []string{"firstnode"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionDrainNoArg(t *testing.T) { - tf, streams := cmdtesting.PrepareNodesForCompletion(t) - cmd := NewCmdDrain(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "f") - cmdtesting.CheckCompletion(t, comps, []string{"firstnode"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionUncordonNoArg(t *testing.T) { - tf, streams := cmdtesting.PrepareNodesForCompletion(t) - cmd := NewCmdUncordon(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "f") - cmdtesting.CheckCompletion(t, comps, []string{"firstnode"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - type MyReq struct { Request *http.Request } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit_test.go index dd89aac8fd2..df1d07ba4a1 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/edit/edit_test.go @@ -283,13 +283,6 @@ func TestEdit(t *testing.T) { } } -func TestCompletionEditOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdEdit(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - func tryIndent(data []byte) []byte { indented := &bytes.Buffer{} if err := json.Indent(indented, data, "", "\t"); err == nil { diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/exec/exec_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/exec/exec_test.go index 7bd7f4c7a2d..814e3e87c44 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/exec/exec_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/exec/exec_test.go @@ -27,7 +27,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -409,10 +408,3 @@ func TestSetupTTY(t *testing.T) { t.Errorf("attach stdin, TTY, is a terminal: tty.Out should equal o.Out") } } - -func TestCompletionExecNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdExec(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go index b1027d8299e..0cb40502012 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/expose/expose_test.go @@ -21,7 +21,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -677,18 +676,3 @@ func TestRunExposeService(t *testing.T) { }) } } - -func TestCompletionExposeNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdExposeService(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - expectedComps := []string{"deployment", "pod", "replicaset", "replicationcontroller", "service"} - cmdtesting.CheckCompletion(t, comps, expectedComps, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionExposeOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdExposeService(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go index 6f1898b28a8..ee0e39a7b66 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go @@ -29,7 +29,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" appsv1 "k8s.io/api/apps/v1" autoscalingv1 "k8s.io/api/autoscaling/v1" batchv1 "k8s.io/api/batch/v1" @@ -2734,13 +2733,6 @@ foo 0/0 0 } } -func TestCompletionGetOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdGet("kubectl", tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - func watchBody(codec runtime.Codec, events []watch.Event) io.ReadCloser { buf := bytes.NewBuffer([]byte{}) enc := restclientwatch.NewEncoder(streaming.NewEncoder(buf, codec), codec) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/label/label_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/label/label_test.go index b8e065c8684..63176eedabe 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/label/label_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/label/label_test.go @@ -24,7 +24,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -566,10 +565,3 @@ func TestLabelResourceVersion(t *testing.T) { t.Fatalf("unexpected error: %v", err) } } - -func TestCompletionLabelOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdLabel(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs_test.go index c40acff99bb..cb9b7cc9228 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs_test.go @@ -30,7 +30,6 @@ import ( "testing/iotest" "time" - "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -834,13 +833,6 @@ func TestNoResourceFoundMessage(t *testing.T) { } } -func TestCompletionLogsNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdLogs(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - type responseWrapperMock struct { data io.Reader err error diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/patch/patch_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/patch/patch_test.go index 0d5ac1f6f71..1fce8bfeda1 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/patch/patch_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/patch/patch_test.go @@ -21,7 +21,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" "k8s.io/client-go/rest/fake" @@ -191,10 +190,3 @@ func TestPatchObjectFromFileOutput(t *testing.T) { t.Errorf("unexpected output: %s", buf.String()) } } - -func TestCompletionPatchOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdPatch(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward_test.go index 058f0db7be7..06b99081ac6 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward_test.go @@ -980,10 +980,3 @@ func TestCheckUDPPort(t *testing.T) { } } } - -func TestCompletionPortForwardNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdPortForward(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_history_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_history_test.go deleted file mode 100644 index 2d1c7b7d91a..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_history_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 rollout - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionRolloutHistoryNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutHistory(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "daemonset", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutHistoryOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutHistory(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_pause_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_pause_test.go index 6f888f97567..779ce0366c4 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_pause_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_pause_test.go @@ -22,7 +22,6 @@ import ( "net/http" "testing" - "github.com/spf13/cobra" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -73,20 +72,6 @@ func TestRolloutPause(t *testing.T) { } } -func TestCompletionRolloutPauseNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutPause(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutPauseOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutPause(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - type RolloutPauseRESTClient struct { *fake.RESTClient } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart_test.go deleted file mode 100644 index b2f1379f14c..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 rollout - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionRolloutRestartNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutRestart(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "daemonset", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutRestartOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutRestart(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_resume_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_resume_test.go deleted file mode 100644 index cf4be53cd4a..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_resume_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 rollout - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionRolloutResumeNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutResume(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutResumeOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutResume(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_status_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_status_test.go deleted file mode 100644 index bcb0eef7627..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_status_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 rollout - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionRolloutStatusNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutStatus(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "daemonset", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutStatusOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutStatus(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_undo_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_undo_test.go deleted file mode 100644 index c28d3767734..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_undo_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 rollout - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionRolloutUndoNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutUndo(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "daemonset", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionRolloutUndoOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdRolloutUndo(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/scale/scale_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/scale/scale_test.go deleted file mode 100644 index 53d5aca3525..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/scale/scale_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 scale - -import ( - "testing" - - "github.com/spf13/cobra" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" -) - -func TestCompletionScaleNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdScale(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"deployment", "replicaset", "replicationcontroller", "statefulset"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionScaleOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdScale(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/taint/taint_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/taint/taint_test.go index 200bd96e0c5..a154c97dfd8 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/taint/taint_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/taint/taint_test.go @@ -24,7 +24,6 @@ import ( "testing" "time" - "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -389,20 +388,6 @@ func TestValidateFlags(t *testing.T) { } } -func TestCompletionTaintNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdTaint(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "") - cmdtesting.CheckCompletion(t, comps, []string{"node"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - -func TestCompletionTaintOneArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdTaint(tf, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{"pods"}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - type MyReq struct { Request *http.Request } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/testing/completion.go b/staging/src/k8s.io/kubectl/pkg/cmd/testing/completion.go deleted file mode 100644 index 6ca72ac8975..00000000000 --- a/staging/src/k8s.io/kubectl/pkg/cmd/testing/completion.go +++ /dev/null @@ -1,158 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -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 - - http://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 testing - -import ( - "io/ioutil" - "net/http" - "os" - "sort" - "testing" - "time" - - "github.com/spf13/cobra" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/cli-runtime/pkg/genericclioptions" - "k8s.io/cli-runtime/pkg/resource" - "k8s.io/client-go/rest/fake" - "k8s.io/client-go/tools/clientcmd" - clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - cmdutil "k8s.io/kubectl/pkg/cmd/util" - "k8s.io/kubectl/pkg/scheme" -) - -// PreparePodsForCompletion prepares the test factory and streams for pods -func PreparePodsForCompletion(t *testing.T) (cmdutil.Factory, genericclioptions.IOStreams) { - pods, _, _ := TestData() - - tf := NewTestFactory().WithNamespace("test") - defer tf.Cleanup() - codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...) - - tf.UnstructuredClient = &fake.RESTClient{ - NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer, - Resp: &http.Response{StatusCode: http.StatusOK, Header: DefaultHeader(), Body: ObjBody(codec, pods)}, - } - - streams, _, _, _ := genericclioptions.NewTestIOStreams() - return tf, streams -} - -// PrepareNodesForCompletion prepares the test factory and streams for pods -func PrepareNodesForCompletion(t *testing.T) (cmdutil.Factory, genericclioptions.IOStreams) { - // TODO create more than one node - // nodes := &corev1.NodeList{ - // ListMeta: metav1.ListMeta{ - // ResourceVersion: "1", - // }, - // Items: []corev1.Node{ - // { - // ObjectMeta: metav1.ObjectMeta{ - // Name: "firstnode", - // CreationTimestamp: metav1.Time{Time: time.Now()}, - // }, - // Status: corev1.NodeStatus{}, - // }, - // { - // ObjectMeta: metav1.ObjectMeta{ - // Name: "secondnode", - // CreationTimestamp: metav1.Time{Time: time.Now()}, - // }, - // Status: corev1.NodeStatus{}, - // }, - // }, - // } - - nodes := &corev1.Node{ - ObjectMeta: metav1.ObjectMeta{ - Name: "firstnode", - CreationTimestamp: metav1.Time{Time: time.Now()}, - }, - Status: corev1.NodeStatus{}, - } - - tf := NewTestFactory() - defer tf.Cleanup() - - codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...) - ns := scheme.Codecs.WithoutConversion() - - tf.UnstructuredClient = &fake.RESTClient{ - NegotiatedSerializer: ns, - Resp: &http.Response{StatusCode: http.StatusOK, Header: DefaultHeader(), Body: ObjBody(codec, nodes)}, - } - - streams, _, _, _ := genericclioptions.NewTestIOStreams() - return tf, streams -} - -// PrepareConfigForCompletion prepares some contexts for completion testing -func PrepareConfigForCompletion(t *testing.T) (*clientcmd.PathOptions, genericclioptions.IOStreams, cmdutil.Factory) { - conf := clientcmdapi.Config{ - Kind: "Config", - APIVersion: "v1", - Clusters: map[string]*clientcmdapi.Cluster{ - "minikube-cluster": {Server: "https://192.168.99.100:8443"}, - "my-cluster": {Server: "https://192.168.0.1:3434"}, - }, - Contexts: map[string]*clientcmdapi.Context{ - "minikube-context": {AuthInfo: "minikube", Cluster: "minikube"}, - "my-context": {AuthInfo: "my-context", Cluster: "my-context"}, - }, - CurrentContext: "minikube-context", - } - - fakeKubeFile, err := ioutil.TempFile(os.TempDir(), "") - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - defer os.Remove(fakeKubeFile.Name()) - err = clientcmd.WriteToFile(conf, fakeKubeFile.Name()) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - pathOptions := clientcmd.NewDefaultPathOptions() - pathOptions.GlobalFile = fakeKubeFile.Name() - pathOptions.EnvVar = "" - - streams, _, _, _ := genericclioptions.NewTestIOStreams() - factory := cmdutil.NewFactory(genericclioptions.NewTestConfigFlags()) - - return pathOptions, streams, factory -} - -// CheckCompletion checks that the directive is correct and that each completion is present -func CheckCompletion(t *testing.T, comps, expectedComps []string, directive, expectedDirective cobra.ShellCompDirective) { - if e, d := expectedDirective, directive; e != d { - t.Errorf("expected directive\n%v\nbut got\n%v", e, d) - } - - sort.Strings(comps) - sort.Strings(expectedComps) - - if len(expectedComps) != len(comps) { - t.Fatalf("expected completions\n%v\nbut got\n%v", expectedComps, comps) - } - - for i := range comps { - if expectedComps[i] != comps[i] { - t.Errorf("expected completions\n%v\nbut got\n%v", expectedComps, comps) - break - } - } -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_node_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_node_test.go index 528b7358ed2..dca44b83f24 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_node_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_node_test.go @@ -25,7 +25,6 @@ import ( "strings" "testing" - "github.com/spf13/cobra" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/genericclioptions" @@ -425,10 +424,3 @@ func TestTopNodeWithSortByMemoryMetricsFrom(t *testing.T) { } } - -func TestCompletionTopNodeNoArg(t *testing.T) { - tf, streams := cmdtesting.PrepareNodesForCompletion(t) - cmd := NewCmdTopNode(tf, nil, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "f") - cmdtesting.CheckCompletion(t, comps, []string{"firstnode"}, directive, cobra.ShellCompDirectiveNoFileComp) -} diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod_test.go index 7986f77bdc0..d8b575cc79f 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod_test.go @@ -26,7 +26,6 @@ import ( "testing" "time" - "github.com/spf13/cobra" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -394,13 +393,6 @@ func TestTopPodNoResourcesFound(t *testing.T) { } } -func TestCompletionTopPodNoArg(t *testing.T) { - tf, streams := cmdtesting.PreparePodsForCompletion(t) - cmd := NewCmdTopPod(tf, nil, streams) - comps, directive := cmd.ValidArgsFunction(cmd, []string{}, "b") - cmdtesting.CheckCompletion(t, comps, []string{"bar"}, directive, cobra.ShellCompDirectiveNoFileComp) -} - func testV1beta1PodMetricsData() []metricsv1beta1api.PodMetrics { return []metricsv1beta1api.PodMetrics{ {