@@ -205,6 +205,19 @@ func TestNewAppRunFailure(t *testing.T) {
205
205
},
206
206
expectedErr : "--search can't be used with --param" ,
207
207
},
208
+ "search_without_argument" : {
209
+ config : & newcmd.AppConfig {
210
+ AsSearch : true ,
211
+ ComponentInputs : newcmd.ComponentInputs {
212
+ DockerImages : []string {"" },
213
+ },
214
+ },
215
+ expectedErr : "no matches found" ,
216
+ },
217
+ "without_args" : {
218
+ config : & newcmd.AppConfig {},
219
+ expectedErr : "You must specify one or more images, image streams, templates, or source code locations to create an application." ,
220
+ },
208
221
}
209
222
210
223
opts := & NewAppOptions {
@@ -318,6 +331,42 @@ func TestNewAppRunQueryActions(t *testing.T) {
318
331
expectedDockerVisited : true ,
319
332
expectedTemplateFilesVisited : true ,
320
333
},
334
+ {
335
+ name : "search template failure" ,
336
+ config : & newcmd.AppConfig {
337
+ AsSearch : true ,
338
+ ComponentInputs : newcmd.ComponentInputs {
339
+ Templates : []string {"non-exist-template" },
340
+ },
341
+ },
342
+ expectedActions : []testAction {
343
+ {namespace : "openshift" , verb : "list" , resource : "templates" },
344
+ },
345
+
346
+ expectedErr : "no matches found" ,
347
+ },
348
+ {
349
+ name : "search imagestream failure" ,
350
+ config : & newcmd.AppConfig {
351
+ AsSearch : true ,
352
+ ComponentInputs : newcmd.ComponentInputs {
353
+ ImageStreams : []string {"#@@#%*" },
354
+ },
355
+ },
356
+ expectedErr : "no matches found" ,
357
+ },
358
+ {
359
+ name : "search dockerimage failure" ,
360
+ config : & newcmd.AppConfig {
361
+ AsSearch : true ,
362
+ ComponentInputs : newcmd.ComponentInputs {
363
+ DockerImages : []string {"fakerepo/non-exist-image" },
364
+ },
365
+ },
366
+ expectedDockerVisited : true ,
367
+ expectedActions : []testAction {},
368
+ expectedErr : "no matches found" ,
369
+ },
321
370
}
322
371
323
372
o := & NewAppOptions {
@@ -351,6 +400,13 @@ func TestNewAppRunQueryActions(t *testing.T) {
351
400
return app.ComponentMatches {match }, []error {}
352
401
},
353
402
}
403
+ o .Config .DockerSearcher = MockSearcher {
404
+ OnSearch : func (precise bool , terms ... string ) (app.ComponentMatches , []error ) {
405
+ dockerVisited = true
406
+ return app.ComponentMatches {}, []error {}
407
+ },
408
+ }
409
+
354
410
o .Config .TemplateFileSearcher = MockSearcher {
355
411
OnSearch : func (precise bool , terms ... string ) (app.ComponentMatches , []error ) {
356
412
tfVisited = true
0 commit comments