mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Fix kubectl version test to tolerate Run error coming from default
localhost:8080
This commit is contained in:
parent
a871738c86
commit
34865774a8
@ -27,6 +27,7 @@ go_test(
|
|||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library",
|
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library",
|
||||||
"//staging/src/k8s.io/kubectl/pkg/cmd/util:go_default_library",
|
"//staging/src/k8s.io/kubectl/pkg/cmd/util:go_default_library",
|
||||||
|
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||||
)
|
)
|
||||||
@ -27,9 +29,17 @@ import (
|
|||||||
func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
||||||
tf := cmdutil.NewFactory(&genericclioptions.ConfigFlags{})
|
tf := cmdutil.NewFactory(&genericclioptions.ConfigFlags{})
|
||||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||||
cmd := NewCmdVersion(tf, streams)
|
o := NewOptions(streams)
|
||||||
cmd.SetOutput(buf)
|
if err := o.Complete(tf, &cobra.Command{}); err != nil {
|
||||||
if err := cmd.Execute(); err != nil {
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if err := o.Validate(); err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
// FIXME soltysh:
|
||||||
|
// since we have defaulting to localhost:8080 in staging/src/k8s.io/client-go/tools/clientcmd/client_config.go#getDefaultServer
|
||||||
|
// we need to ignore the localhost:8080 server, when above gets removed this should be dropped too
|
||||||
|
if err := o.Run(); err != nil && !strings.Contains(err.Error(), "localhost:8080") {
|
||||||
t.Errorf("Cannot execute version command: %v", err)
|
t.Errorf("Cannot execute version command: %v", err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(buf.String(), "Client Version") {
|
if !strings.Contains(buf.String(), "Client Version") {
|
||||||
|
Loading…
Reference in New Issue
Block a user