@@ -101,31 +101,31 @@ func TestPluginPathsAreValid(t *testing.T) {
101
101
expectOut string
102
102
}{
103
103
{
104
- name : "ensure no plugins found if no files begin with kubectl- prefix" ,
105
- pluginPaths : []string {tempDir },
106
- verifier : newFakePluginPathVerifier (),
107
- pluginFile : func () (* os.File , error ) {
104
+ name : "ensure no plugins found if no files begin with kubectl- prefix" ,
105
+ pluginPaths : []string {tempDir },
106
+ verifier : newFakePluginPathVerifier (),
107
+ pluginFile : func () (* os.File , error ) {
108
108
return ioutil .TempFile (tempDir , "notkubectl-" )
109
109
},
110
- expectErr : " unable to find any kubectl plugins in your PATH" ,
110
+ expectErr : "error: unable to find any kubectl plugins in your PATH\n " ,
111
111
},
112
112
{
113
- name : "ensure de-duplicated plugin-paths slice" ,
114
- pluginPaths : []string {tempDir , tempDir },
115
- verifier : newFakePluginPathVerifier (),
116
- pluginFile : func () (* os.File , error ) {
113
+ name : "ensure de-duplicated plugin-paths slice" ,
114
+ pluginPaths : []string {tempDir , tempDir },
115
+ verifier : newFakePluginPathVerifier (),
116
+ pluginFile : func () (* os.File , error ) {
117
117
return ioutil .TempFile (tempDir , "kubectl-" )
118
118
},
119
- expectOut : "The following compatible plugins are available:" ,
119
+ expectOut : "The following compatible plugins are available:" ,
120
120
},
121
121
{
122
- name : "ensure no errors when empty string or blank path are specified" ,
123
- pluginPaths : []string {tempDir , "" , " " },
124
- verifier : newFakePluginPathVerifier (),
125
- pluginFile : func () (* os.File , error ) {
122
+ name : "ensure no errors when empty string or blank path are specified" ,
123
+ pluginPaths : []string {tempDir , "" , " " },
124
+ verifier : newFakePluginPathVerifier (),
125
+ pluginFile : func () (* os.File , error ) {
126
126
return ioutil .TempFile (tempDir , "kubectl-" )
127
127
},
128
- expectOut : "The following compatible plugins are available:" ,
128
+ expectOut : "The following compatible plugins are available:" ,
129
129
},
130
130
}
131
131
@@ -138,8 +138,6 @@ func TestPluginPathsAreValid(t *testing.T) {
138
138
139
139
PluginPaths : test .pluginPaths ,
140
140
}
141
- o .Out = out
142
- o .ErrOut = errOut
143
141
144
142
// create files
145
143
if test .pluginFile != nil {
@@ -158,10 +156,11 @@ func TestPluginPathsAreValid(t *testing.T) {
158
156
159
157
err := o .Run ()
160
158
if err == nil && len (test .expectErr ) > 0 {
161
- t .Fatalf ("unexpected non-error: expecting %v" , test .expectErr )
162
- }
163
- if err != nil && len (test .expectErr ) == 0 {
164
- t .Fatalf ("unexpected error: %v - %v" , err , errOut .String ())
159
+ t .Fatalf ("unexpected non-error: expected %v, but got nothing" , test .expectErr )
160
+ } else if err != nil && len (test .expectErr ) == 0 {
161
+ t .Fatalf ("unexpected error: expected nothing, but got %v" , err .Error ())
162
+ } else if err != nil && err .Error () != test .expectErr {
163
+ t .Fatalf ("unexpected error: expected %v, but got %v" , test .expectErr , err .Error ())
165
164
}
166
165
167
166
if len (test .expectErrOut ) == 0 && errOut .Len () > 0 {
0 commit comments