@@ -17,7 +17,6 @@ import { Progress } from '../../../src/util/progress';
1717import * as Util from '../../../src/util/async' ;
1818import { Refs } from '../../../src/util/refs' ;
1919import OpenShiftItem from '../../../src/openshift/openshiftItem' ;
20- import { SourceTypeChoice } from '../../../src/openshift/component' ;
2120import { SourceType } from '../../../src/odo/config' ;
2221import { ComponentKind , ComponentTypeAdapter } from '../../../src/odo/componentType' ;
2322import { AddWorkspaceFolder } from '../../../src/util/workspace' ;
@@ -111,9 +110,8 @@ suite('OpenShift/Component', () => {
111110
112111 setup ( ( ) => {
113112 quickPickStub = sandbox . stub ( vscode . window , 'showQuickPick' ) ;
114- quickPickStub . onFirstCall ( ) . resolves ( SourceTypeChoice . LOCAL ) ;
115- quickPickStub . onSecondCall ( ) . resolves ( { label : 'file:///c:/Temp' , folder : vscode . Uri . parse ( 'file:///c:/Temp' ) } ) ;
116- quickPickStub . onThirdCall ( ) . resolves ( componentType ) ;
113+ quickPickStub . onFirstCall ( ) . resolves ( { label : 'file:///c:/Temp' , folder : vscode . Uri . parse ( 'file:///c:/Temp' ) } ) ;
114+ quickPickStub . onSecondCall ( ) . resolves ( componentType ) ;
117115 inputStub = sandbox . stub ( vscode . window , 'showInputBox' ) ;
118116 progressFunctionStub = sandbox . stub ( Progress , 'execFunctionWithProgress' ) . yields ( ) ;
119117 sandbox . stub ( vscode . workspace , 'workspaceFolders' ) . value ( [ wsFolder1 , wsFolder2 ] ) ;
@@ -127,7 +125,7 @@ suite('OpenShift/Component', () => {
127125 } ) ;
128126
129127 test ( 'errors when a subcommand fails' , async ( ) => {
130- quickPickStub . onSecondCall ( ) . rejects ( errorMessage ) ;
128+ quickPickStub . onFirstCall ( ) . rejects ( errorMessage ) ;
131129 let expectedError : Error ;
132130 try {
133131 await Component . create ( appItem ) ;
@@ -141,7 +139,7 @@ suite('OpenShift/Component', () => {
141139
142140 setup ( ( ) => {
143141 inputStub . resolves ( componentItem . getName ( ) ) ;
144- quickPickStub . onSecondCall ( ) . resolves ( { label : folder . uri . fsPath , uri : folder . uri } ) ;
142+ quickPickStub . onFirstCall ( ) . resolves ( { label : folder . uri . fsPath , uri : folder . uri } ) ;
145143 } ) ;
146144
147145 test ( 'happy path works' , async ( ) => {
@@ -160,22 +158,22 @@ suite('OpenShift/Component', () => {
160158 } ) ;
161159
162160 test ( 'returns null when no folder selected' , async ( ) => {
163- quickPickStub . onSecondCall ( ) . resolves ( undefined ) ;
161+ quickPickStub . onFirstCall ( ) . resolves ( undefined ) ;
164162 const result = await Component . create ( appItem ) ;
165163
166164 expect ( result ) . null ;
167165 } ) ;
168166
169167 test ( 'returns null when no new context folder selected' , async ( ) => {
170- quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder ) ;
168+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
171169 sandbox . stub ( vscode . window , 'showOpenDialog' ) . resolves ( null ) ;
172170 const result = await Component . create ( appItem ) ;
173171
174172 expect ( result ) . null ;
175173 } ) ;
176174
177175 test ( 'returns null when no new context folder selected' , async ( ) => {
178- quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder ) ;
176+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
179177 sandbox . stub ( vscode . window , 'showOpenDialog' ) . resolves ( null ) ;
180178 const result = await Component . create ( appItem ) ;
181179
@@ -185,9 +183,8 @@ suite('OpenShift/Component', () => {
185183 test ( 'ask again to select new context folder if selected one has odo component in it' , async ( ) => {
186184 quickPickStub . restore ( ) ;
187185 quickPickStub = sandbox . stub ( vscode . window , 'showQuickPick' ) ;
188- quickPickStub . onFirstCall ( ) . resolves ( SourceTypeChoice . LOCAL ) ;
189- quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder ) ;
190- quickPickStub . onThirdCall ( ) . resolves ( AddWorkspaceFolder )
186+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
187+ quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder )
191188 const sod = sandbox . stub ( vscode . window , 'showOpenDialog' ) ;
192189 sod . onFirstCall ( ) . resolves ( [ vscode . Uri . parse ( 'file:///c%3A/Temp' ) ] ) ;
193190 sandbox . stub ( fs , 'existsSync' ) . returns ( true ) ;
@@ -207,7 +204,7 @@ suite('OpenShift/Component', () => {
207204 } ) ;
208205
209206 test ( 'returns null when no component type selected' , async ( ) => {
210- quickPickStub . onThirdCall ( ) . resolves ( undefined ) ;
207+ quickPickStub . onSecondCall ( ) . resolves ( undefined ) ;
211208 const result = await Component . create ( appItem ) ;
212209
213210 expect ( result ) . null ;
@@ -218,12 +215,11 @@ suite('OpenShift/Component', () => {
218215 const uri = 'git uri' ;
219216 setup ( ( ) => {
220217 sandbox . stub ( OdoImpl . prototype , 'getComponentTypes' ) . resolves ( [ 'nodejs' ] ) ;
221- quickPickStub . onFirstCall ( ) . resolves ( SourceTypeChoice . GIT ) ;
222- quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder ) ;
218+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
223219 inputStub . onFirstCall ( ) . resolves ( uri ) ;
224- quickPickStub . onThirdCall ( ) . resolves ( 'master' ) ;
225- quickPickStub . onCall ( 3 ) . resolves ( componentType ) ;
226- quickPickStub . onCall ( 4 ) . resolves ( version ) ;
220+ quickPickStub . onSecondCall ( ) . resolves ( 'master' ) ;
221+ quickPickStub . onThirdCall ( ) . resolves ( componentType ) ;
222+ quickPickStub . onCall ( 3 ) . resolves ( version ) ;
227223 inputStub . onSecondCall ( ) . resolves ( componentItem . getName ( ) ) ;
228224 sandbox . stub ( vscode . window , 'showInformationMessage' ) . resolves ( ) ;
229225 sandbox . stub ( vscode . window , 'showOpenDialog' ) . resolves ( [ vscode . Uri . parse ( 'file:///c%3A/Temp' ) ] ) ;
@@ -242,36 +238,36 @@ suite('OpenShift/Component', () => {
242238 } ) ;
243239
244240 test ( 'happy path works' , async ( ) => {
245- const result = await Component . create ( appItem ) ;
241+ const result = await Component . createFromGit ( appItem ) ;
246242
247243 expect ( result ) . equals ( `Component '${ componentItem . getName ( ) } ' successfully created. To deploy it on cluster, perform 'Push' action.` ) ;
248244 expect ( execStub ) . calledWith ( Command . createGitComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentType . name , version , componentItem . getName ( ) , uri , ref ) ) ;
249245 } ) ;
250246
251247 test ( 'returns null when no git repo selected' , async ( ) => {
252248 inputStub . onFirstCall ( ) . resolves ( ) ;
253- const result = await Component . create ( appItem ) ;
249+ const result = await Component . createFromGit ( appItem ) ;
254250
255251 expect ( result ) . null ;
256252 } ) ;
257253
258254 test ( 'returns null when no component name selected' , async ( ) => {
259- inputStub . onSecondCall ( ) . resolves ( ) ;
260- const result = await Component . create ( appItem ) ;
255+ inputStub . onFirstCall ( ) . resolves ( ) ;
256+ const result = await Component . createFromGit ( appItem ) ;
261257
262258 expect ( result ) . null ;
263259 } ) ;
264260
265261 test ( 'returns null when no git reference selected' , async ( ) => {
266- quickPickStub . onThirdCall ( ) . resolves ( ) ;
267- const result = await Component . create ( appItem ) ;
262+ quickPickStub . onSecondCall ( ) . resolves ( ) ;
263+ const result = await Component . createFromGit ( appItem ) ;
268264
269265 expect ( result ) . null ;
270266 } ) ;
271267
272268 test ( 'returns null when no component type selected' , async ( ) => {
273- quickPickStub . onCall ( 3 ) . resolves ( ) ;
274- const result = await Component . create ( appItem ) ;
269+ quickPickStub . onCall ( 2 ) . resolves ( ) ;
270+ const result = await Component . createFromGit ( appItem ) ;
275271
276272 expect ( result ) . null ;
277273 } ) ;
@@ -283,7 +279,7 @@ suite('OpenShift/Component', () => {
283279 return Promise . resolve ( 'https://github.com/redhat-developer/vscode-openshift-tools' ) ;
284280 } ) ;
285281
286- await Component . create ( appItem ) ;
282+ await Component . createFromGit ( appItem ) ;
287283 expect ( result ) . to . be . undefined ;
288284 } ) ;
289285
@@ -295,7 +291,7 @@ suite('OpenShift/Component', () => {
295291 return Promise . resolve ( 'https://github.com' ) ;
296292 } ) ;
297293
298- await Component . create ( appItem ) ;
294+ await Component . createFromGit ( appItem ) ;
299295 expect ( result ) . equals ( 'There is no git repository at provided URL.' ) ;
300296 } ) ;
301297
@@ -306,7 +302,7 @@ suite('OpenShift/Component', () => {
306302 return Promise . resolve ( 'github' ) ;
307303 } ) ;
308304
309- await Component . create ( appItem ) ;
305+ await Component . createFromGit ( appItem ) ;
310306 expect ( result ) . equals ( 'Invalid URL provided' ) ;
311307 } ) ;
312308
@@ -317,7 +313,7 @@ suite('OpenShift/Component', () => {
317313 return Promise . resolve ( '' ) ;
318314 } ) ;
319315
320- await Component . create ( appItem ) ;
316+ await Component . createFromGit ( appItem ) ;
321317 expect ( result ) . equals ( 'Empty Git repository URL' ) ;
322318 } ) ;
323319 } ) ;
@@ -346,47 +342,47 @@ suite('OpenShift/Component', () => {
346342 } ] ;
347343
348344 setup ( ( ) => {
349- quickPickStub . onFirstCall ( ) . resolves ( SourceTypeChoice . BINARY ) ;
350- quickPickStub . onSecondCall ( ) . resolves ( AddWorkspaceFolder ) ;
351- quickPickStub . onThirdCall ( ) . resolves ( {
345+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
346+ quickPickStub . onSecondCall ( ) . resolves ( {
352347 description : paths ,
353348 label : '$(file-zip) sb.jar'
354349 } ) ;
355- quickPickStub . onCall ( 3 ) . resolves ( componentType ) ;
356- quickPickStub . onCall ( 4 ) . resolves ( version ) ;
350+ quickPickStub . onThirdCall ( ) . resolves ( componentType ) ;
351+ quickPickStub . onCall ( 3 ) . resolves ( version ) ;
357352 sandbox . stub ( vscode . window , 'showOpenDialog' ) . resolves ( files ) ;
358353 globbyStub = sandbox . stub ( globby , 'sync' ) . returns ( [ paths ] ) ;
359354 inputStub . resolves ( componentItem . getName ( ) ) ;
360355 } ) ;
361356
362357 test ( 'happy path works' , async ( ) => {
363- const result = await Component . create ( appItem ) ;
358+ const result = await Component . createFromBinary ( appItem ) ;
364359
365360 expect ( result ) . equals ( `Component '${ componentItem . getName ( ) } ' successfully created. To deploy it on cluster, perform 'Push' action.` ) ;
366361 expect ( execStub ) . calledWith ( Command . createBinaryComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentType . name , version , componentItem . getName ( ) , paths , files [ 0 ] . fsPath ) ) ;
367362 } ) ;
368363
369364 test ( 'returns null when no option is selected from quick pick' , async ( ) => {
370- quickPickStub . onFirstCall ( ) . resolves ( undefined ) ;
365+ quickPickStub . onSecondCall ( ) . resolves ( undefined ) ;
371366 const result = await Component . createFromBinary ( null ) ;
372367 expect ( result ) . null ;
373368 } ) ;
374369
375370 test ( 'returns information message if no binary file present in the context' , async ( ) => {
371+ quickPickStub . onFirstCall ( ) . resolves ( AddWorkspaceFolder ) ;
376372 globbyStub . onFirstCall ( ) . returns ( [ ] ) ;
377- const result = await Component . createFromBinary ( null ) ;
373+ const result = await Component . createFromBinary ( appItem ) ;
378374 expect ( result ) . equals ( 'No binary file present in the context folder selected. We currently only support .jar and .war files. If you need support for any other file, please raise an issue.' ) ;
379375 } ) ;
380376
381377 test ( 'returns null when no work space folder selected' , async ( ) => {
382- quickPickStub . onSecondCall ( ) . resolves ( undefined ) ;
383- const result = await Component . create ( appItem ) ;
378+ quickPickStub . onFirstCall ( ) . resolves ( undefined ) ;
379+ const result = await Component . createFromBinary ( appItem ) ;
384380
385381 expect ( result ) . null ;
386382 } ) ;
387383
388384 test ( 'returns null when no binary file selected' , async ( ) => {
389- quickPickStub . onThirdCall ( ) . resolves ( undefined ) ;
385+ quickPickStub . onSecondCall ( ) . resolves ( undefined ) ;
390386 const result = await Component . create ( appItem ) ;
391387
392388 expect ( result ) . null ;
@@ -400,8 +396,8 @@ suite('OpenShift/Component', () => {
400396 } ) ;
401397
402398 test ( 'returns null when no component type selected' , async ( ) => {
403- quickPickStub . onCall ( 3 ) . resolves ( ) ;
404- const result = await Component . create ( appItem ) ;
399+ quickPickStub . onThirdCall ( ) . resolves ( ) ;
400+ const result = await Component . createFromBinary ( appItem ) ;
405401
406402 expect ( result ) . null ;
407403 } ) ;
0 commit comments