@@ -17,16 +17,12 @@ limitations under the License.
17
17
package cmd
18
18
19
19
import (
20
- "bytes"
21
20
"fmt"
22
21
"io/ioutil"
23
22
"os"
24
23
"reflect"
25
- "strings"
26
24
"testing"
27
25
28
- "github.com/spf13/cobra"
29
-
30
26
"k8s.io/cli-runtime/pkg/genericclioptions"
31
27
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
32
28
)
@@ -57,56 +53,6 @@ func TestNormalizationFuncGlobalExistence(t *testing.T) {
57
53
}
58
54
}
59
55
60
- func Test_deprecatedAlias (t * testing.T ) {
61
- var correctCommandCalled bool
62
- makeCobraCommand := func () * cobra.Command {
63
- cobraCmd := new (cobra.Command )
64
- cobraCmd .Use = "print five lines"
65
- cobraCmd .Run = func (* cobra.Command , []string ) {
66
- correctCommandCalled = true
67
- }
68
- return cobraCmd
69
- }
70
-
71
- original := makeCobraCommand ()
72
- alias := deprecatedAlias ("echo" , makeCobraCommand ())
73
-
74
- if len (alias .Deprecated ) == 0 {
75
- t .Error ("deprecatedAlias should always have a non-empty .Deprecated" )
76
- }
77
- if ! strings .Contains (alias .Deprecated , "print" ) {
78
- t .Error ("deprecatedAlias should give the name of the new function in its .Deprecated field" )
79
- }
80
- if ! alias .Hidden {
81
- t .Error ("deprecatedAlias should never have .Hidden == false (deprecated aliases should be hidden)" )
82
- }
83
-
84
- if alias .Name () != "echo" {
85
- t .Errorf ("deprecatedAlias has name %q, expected %q" ,
86
- alias .Name (), "echo" )
87
- }
88
- if original .Name () != "print" {
89
- t .Errorf ("original command has name %q, expected %q" ,
90
- original .Name (), "print" )
91
- }
92
-
93
- buffer := new (bytes.Buffer )
94
- alias .SetOutput (buffer )
95
- alias .Execute ()
96
- str := buffer .String ()
97
- if ! strings .Contains (str , "deprecated" ) || ! strings .Contains (str , "print" ) {
98
- t .Errorf ("deprecation warning %q does not include enough information" , str )
99
- }
100
-
101
- // It would be nice to test to see that original.Run == alias.Run
102
- // Unfortunately Golang does not allow comparing functions. I could do
103
- // this with reflect, but that's technically invoking undefined
104
- // behavior. Best we can do is make sure that the function is called.
105
- if ! correctCommandCalled {
106
- t .Errorf ("original function doesn't appear to have been called by alias" )
107
- }
108
- }
109
-
110
56
func TestKubectlCommandHandlesPlugins (t * testing.T ) {
111
57
tests := []struct {
112
58
name string
0 commit comments