mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
Revert "Add Go tests for custom completions"
This reverts commit 0e18f0380042b652996d795559bfb818698abec3.
This commit is contained in:
parent
9625872d1e
commit
1babceac65
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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"},
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 <unknown>
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user