@@ -280,6 +280,22 @@ describe("BundlePusher01", () => {
280
280
expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
281
281
expect ( submitSpy ) . toHaveBeenCalledTimes ( 1 ) ;
282
282
} ) ;
283
+ it ( "should tolerate delete of empty directory" , async ( ) => {
284
+ shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
285
+ stdoutHandler ( "Injected FSUM9195 empty directory message" ) ;
286
+ } ) ;
287
+
288
+ await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
289
+ "PUSH operation completed." ) ;
290
+
291
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
292
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
293
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
294
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
295
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
296
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
297
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 2 ) ;
298
+ } ) ;
283
299
it ( "should handle error with attribs file" , async ( ) => {
284
300
existsSpy . mockImplementation ( ( data : string ) => {
285
301
if ( data . indexOf ( ".zosattributes" ) > - 1 ) {
@@ -308,6 +324,50 @@ describe("BundlePusher01", () => {
308
324
expect ( existsSpy ) . toHaveBeenCalledTimes ( 1 ) ;
309
325
expect ( readSpy ) . toHaveBeenCalledTimes ( 2 ) ;
310
326
} ) ;
327
+ it ( "should load zosattribs file" , async ( ) => {
328
+ existsSpy . mockImplementation ( ( data : string ) => {
329
+ if ( data . indexOf ( ".zosattributes" ) > - 1 ) {
330
+ return true ;
331
+ }
332
+ } ) ;
333
+ readSpy . mockImplementation ( ( data : string ) => {
334
+ if ( data . indexOf ( ".zosattributes" ) > - 1 ) {
335
+ return "" ;
336
+ }
337
+ else if ( data . indexOf ( "cics.xml" ) > - 1 ) {
338
+ return "<manifest xmlns=\"http://www.ibm.com/xmlns/prod/cics/bundle\"></manifest>" ;
339
+ }
340
+ } ) ;
341
+
342
+ await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
343
+ "PUSH operation completed." ) ;
344
+
345
+ expect ( consoleText ) . not . toContain ( "WARNING: No .zosAttributes file found in the bundle directory, default values will be applied." ) ;
346
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
347
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
348
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
349
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
350
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
351
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
352
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 2 ) ;
353
+ expect ( existsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
354
+ expect ( readSpy ) . toHaveBeenCalledTimes ( 2 ) ;
355
+ } ) ;
356
+ it ( "should use a default zosattribs file" , async ( ) => {
357
+ await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
358
+ "PUSH operation completed." ) ;
359
+
360
+ expect ( consoleText ) . toContain ( "WARNING: No .zosAttributes file found in the bundle directory, default values will be applied." ) ;
361
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
362
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
363
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
364
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
365
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
366
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
367
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 2 ) ;
368
+ expect ( existsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
369
+ expect ( readSpy ) . toHaveBeenCalledTimes ( 1 ) ;
370
+ } ) ;
311
371
it ( "should handle error with bundle upload" , async ( ) => {
312
372
uploadSpy . mockImplementationOnce ( ( ) => { throw new Error ( "Injected upload error" ) ; } ) ;
313
373
@@ -421,7 +481,8 @@ describe("BundlePusher01", () => {
421
481
} ) ;
422
482
423
483
await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
424
- "A problem occurred attempting to run 'npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
484
+ "A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/IBM/node-latest-os390-s390x/bin\" " +
485
+ "&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
425
486
"Problem is: The output from the remote command implied that an error occurred." ) ;
426
487
427
488
expect ( consoleText ) . toContain ( "Injected stdout error message" ) ;
@@ -436,6 +497,76 @@ describe("BundlePusher01", () => {
436
497
expect ( readSpy ) . toHaveBeenCalledTimes ( 1 ) ;
437
498
expect ( uploadSpy ) . toHaveBeenCalledTimes ( 1 ) ;
438
499
} ) ;
500
+ it ( "should handle failure of remote npm install with FSUM message" , async ( ) => {
501
+ shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
502
+ if ( cmd . indexOf ( "npm install" ) > - 1 ) {
503
+ stdoutHandler ( "Injected FSUM7351 not found message" ) ;
504
+ }
505
+ else {
506
+ return true ;
507
+ }
508
+ } ) ;
509
+ existsSpy . mockImplementation ( ( data : string ) => {
510
+ if ( data . indexOf ( ".zosattributes" ) > - 1 ) {
511
+ return false ;
512
+ }
513
+ if ( data . indexOf ( "package.json" ) > - 1 ) {
514
+ return true ;
515
+ }
516
+ } ) ;
517
+
518
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
519
+ "A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/IBM/node-latest-os390-s390x/bin\" " +
520
+ "&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
521
+ "Problem is: The output from the remote command implied that an error occurred." ) ;
522
+
523
+ expect ( consoleText ) . toContain ( "Injected FSUM7351 not found message" ) ;
524
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
525
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
526
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
527
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
528
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
529
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 0 ) ;
530
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 0 ) ;
531
+ expect ( existsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
532
+ expect ( readSpy ) . toHaveBeenCalledTimes ( 1 ) ;
533
+ expect ( uploadSpy ) . toHaveBeenCalledTimes ( 1 ) ;
534
+ } ) ;
535
+ it ( "should handle failure of remote npm install with node error" , async ( ) => {
536
+ shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
537
+ if ( cmd . indexOf ( "npm install" ) > - 1 ) {
538
+ stdoutHandler ( "Injected npm ERR! Exit status 1 message" ) ;
539
+ }
540
+ else {
541
+ return true ;
542
+ }
543
+ } ) ;
544
+ existsSpy . mockImplementation ( ( data : string ) => {
545
+ if ( data . indexOf ( ".zosattributes" ) > - 1 ) {
546
+ return false ;
547
+ }
548
+ if ( data . indexOf ( "package.json" ) > - 1 ) {
549
+ return true ;
550
+ }
551
+ } ) ;
552
+
553
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
554
+ "A problem occurred attempting to run 'export PATH=\"$PATH:/usr/lpp/IBM/cnj/IBM/node-latest-os390-s390x/bin\" " +
555
+ "&& npm install' in remote directory '/u/ThisDoesNotExist/12345678'. " +
556
+ "Problem is: The output from the remote command implied that an error occurred." ) ;
557
+
558
+ expect ( consoleText ) . toContain ( "Injected npm ERR! Exit status 1 message" ) ;
559
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
560
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
561
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
562
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
563
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
564
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 0 ) ;
565
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 0 ) ;
566
+ expect ( existsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
567
+ expect ( readSpy ) . toHaveBeenCalledTimes ( 1 ) ;
568
+ expect ( uploadSpy ) . toHaveBeenCalledTimes ( 1 ) ;
569
+ } ) ;
439
570
it ( "should handle error with remote bundle deploy" , async ( ) => {
440
571
submitSpy . mockImplementationOnce ( ( ) => { throw new Error ( "Injected deploy error" ) ; } ) ;
441
572
0 commit comments