File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
staging/src/k8s.io/kubectl/pkg/cmd/version Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ go_test(
27
27
deps = [
28
28
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library" ,
29
29
"//staging/src/k8s.io/kubectl/pkg/cmd/util:go_default_library" ,
30
+ "//vendor/github.com/spf13/cobra:go_default_library" ,
30
31
],
31
32
)
32
33
Original file line number Diff line number Diff line change @@ -20,16 +20,26 @@ import (
20
20
"strings"
21
21
"testing"
22
22
23
+ "github.com/spf13/cobra"
24
+
23
25
"k8s.io/cli-runtime/pkg/genericclioptions"
24
26
cmdutil "k8s.io/kubectl/pkg/cmd/util"
25
27
)
26
28
27
29
func TestNewCmdVersionWithoutConfigFile (t * testing.T ) {
28
30
tf := cmdutil .NewFactory (& genericclioptions.ConfigFlags {})
29
31
streams , _ , buf , _ := genericclioptions .NewTestIOStreams ()
30
- cmd := NewCmdVersion (tf , streams )
31
- cmd .SetOutput (buf )
32
- if err := cmd .Execute (); err != nil {
32
+ o := NewOptions (streams )
33
+ if err := o .Complete (tf , & cobra.Command {}); err != nil {
34
+ t .Errorf ("Unexpected error: %v" , err )
35
+ }
36
+ if err := o .Validate (); err != nil {
37
+ t .Errorf ("Unexpected error: %v" , err )
38
+ }
39
+ // FIXME soltysh:
40
+ // since we have defaulting to localhost:8080 in staging/src/k8s.io/client-go/tools/clientcmd/client_config.go#getDefaultServer
41
+ // we need to ignore the localhost:8080 server, when above gets removed this should be dropped too
42
+ if err := o .Run (); err != nil && ! strings .Contains (err .Error (), "localhost:8080" ) {
33
43
t .Errorf ("Cannot execute version command: %v" , err )
34
44
}
35
45
if ! strings .Contains (buf .String (), "Client Version" ) {
You can’t perform that action at this time.
0 commit comments