Fix kubectl version test to tolerate Run error coming from default
localhost:8080 Kubernetes-commit: 34865774a89db5f5b8684d5dd1042f6f4c2b21d0
This commit is contained in:
parent
44044e1c83
commit
e6776b41f6
|
@ -20,6 +20,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
)
|
||||
|
@ -27,9 +29,17 @@ import (
|
|||
func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
||||
tf := cmdutil.NewFactory(&genericclioptions.ConfigFlags{})
|
||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
cmd := NewCmdVersion(tf, streams)
|
||||
cmd.SetOutput(buf)
|
||||
if err := cmd.Execute(); err != nil {
|
||||
o := NewOptions(streams)
|
||||
if err := o.Complete(tf, &cobra.Command{}); 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)
|
||||
}
|
||||
if !strings.Contains(buf.String(), "Client Version") {
|
||||
|
|
Loading…
Reference in New Issue