mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +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"
|
||||
|
||||
"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) {
|
||||
tf := cmdutil.NewFactory(&genericclioptions.ConfigFlags{})
|
||||
func TestNewCmdVersionClientVersion(t *testing.T) {
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
o := NewOptions(streams)
|
||||
if err := o.Complete(tf, &cobra.Command{}); err != nil {
|
||||
@ -36,10 +37,7 @@ func TestNewCmdVersionWithoutConfigFile(t *testing.T) {
|
||||
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") {
|
||||
if err := o.Run(); err != nil {
|
||||
t.Errorf("Cannot execute version command: %v", err)
|
||||
}
|
||||
if !strings.Contains(buf.String(), "Client Version") {
|
||||
|
Loading…
Reference in New Issue
Block a user