mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-06-09 08:51:18 -04:00
Fix kubectl version unit test
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com> Kubernetes-commit: 93ef5acb35f40e6cb5aae3297858371349fed10a
This commit is contained in:
parent
6be23e208d
commit
3e89fad72d
1 changed files with 5 additions and 7 deletions
|
|
@ -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 a new issue