mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Fix kubectl version unit test
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>
This commit is contained in:
parent
d92b788faa
commit
93ef5acb35
@ -23,11 +23,12 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
func TestNewCmdVersionClientVersion(t *testing.T) {
|
||||||
tf := cmdutil.NewFactory(&genericclioptions.ConfigFlags{})
|
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||||
|
defer tf.Cleanup()
|
||||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||||
o := NewOptions(streams)
|
o := NewOptions(streams)
|
||||||
if err := o.Complete(tf, &cobra.Command{}); err != nil {
|
if err := o.Complete(tf, &cobra.Command{}); err != nil {
|
||||||
@ -36,10 +37,7 @@ func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
|||||||
if err := o.Validate(); err != nil {
|
if err := o.Validate(); err != nil {
|
||||||
t.Errorf("Unexpected error: %v", err)
|
t.Errorf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
// FIXME soltysh:
|
if err := o.Run(); err != nil {
|
||||||
// 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