@@ -70,7 +70,7 @@ let createSpy = jest.spyOn(Create, "uss").mockImplementation(() => ({}));
70
70
let listSpy = jest . spyOn ( List , "fileList" ) . mockImplementation ( ( ) => ( { } ) ) ;
71
71
let membersSpy = jest . spyOn ( List , "allMembers" ) . mockImplementation ( ( ) => ( { } ) ) ;
72
72
let submitSpy = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementation ( ( ) => ( { } ) ) ;
73
- let shellSpy = jest . spyOn ( Shell , "executeSshCwd" ) . mockImplementation ( ( ) => ( { } ) ) ;
73
+ let shellSpy = jest . spyOn ( Shell , "executeSshCwd" ) . mockImplementation ( ( ) => ( 0 ) ) ;
74
74
let existsSpy = jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( ) => ( { } ) ) ;
75
75
let readSpy = jest . spyOn ( fs , "readFileSync" ) . mockImplementation ( ( ) => ( { } ) ) ;
76
76
let uploadSpy = jest . spyOn ( Upload , "dirToUSSDirRecursive" ) . mockImplementation ( ( ) => ( { } ) ) ;
@@ -88,7 +88,7 @@ describe("BundlePusher01", () => {
88
88
membersSpy = jest . spyOn ( List , "allMembers" ) . mockImplementation ( ( ) => ( { val : "DFHDPLOY, EYU9ABSI" } ) ) ;
89
89
submitSpy = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementation ( ( ) =>
90
90
[ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2012I" } ] ) ;
91
- shellSpy = jest . spyOn ( Shell , "executeSshCwd" ) . mockImplementation ( ( ) => ( { } ) ) ;
91
+ shellSpy = jest . spyOn ( Shell , "executeSshCwd" ) . mockImplementation ( ( ) => ( 0 ) ) ;
92
92
existsSpy = jest . spyOn ( fs , "existsSync" ) . mockReturnValue ( false ) ;
93
93
readSpy = jest . spyOn ( fs , "readFileSync" ) . mockImplementation ( ( data : string ) => {
94
94
if ( data . indexOf ( "cics.xml" ) > - 1 ) {
@@ -393,6 +393,7 @@ describe("BundlePusher01", () => {
393
393
it ( "should tolerate delete of empty directory" , async ( ) => {
394
394
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
395
395
stdoutHandler ( "FSUM9195 cannot unlink entry \"*\": EDC5129I No such file or directory." ) ;
396
+ return 1 ;
396
397
} ) ;
397
398
398
399
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
@@ -406,9 +407,48 @@ describe("BundlePusher01", () => {
406
407
expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
407
408
expect ( submitSpy ) . toHaveBeenCalledTimes ( 2 ) ;
408
409
} ) ;
410
+ it ( "should not tolerate non zero return code from ssh command" , async ( ) => {
411
+ shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
412
+ stdoutHandler ( "Ssh command exit with non zero status" ) ;
413
+ return 1 ;
414
+ } ) ;
415
+
416
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , true ,
417
+ "A problem occurred attempting to run 'rm -r *' in remote directory '/u/ThisDoesNotExist/12345678'. " +
418
+ "Problem is: The output from the remote command implied that an error occurred." ) ;
419
+
420
+ expect ( consoleText ) . toContain ( "Ssh command exit with non zero status" ) ;
421
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
422
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
423
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
424
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
425
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
426
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
427
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 1 ) ;
428
+ } ) ;
429
+ it ( "should not tolerate mixture of FSUM9195 but exit status is not 1" , async ( ) => {
430
+ shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
431
+ stdoutHandler ( "Injected FSUM9195 error message" ) ;
432
+ return 127 ;
433
+ } ) ;
434
+
435
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , true ,
436
+ "A problem occurred attempting to run 'rm -r *' in remote directory '/u/ThisDoesNotExist/12345678'. " +
437
+ "Problem is: The output from the remote command implied that an error occurred." ) ;
438
+
439
+ expect ( consoleText ) . toContain ( "Injected FSUM9195 error message" ) ;
440
+ expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
441
+ expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
442
+ expect ( createSpy ) . toHaveBeenCalledTimes ( 1 ) ;
443
+ expect ( listSpy ) . toHaveBeenCalledTimes ( 1 ) ;
444
+ expect ( shellSpy ) . toHaveBeenCalledTimes ( 1 ) ;
445
+ expect ( membersSpy ) . toHaveBeenCalledTimes ( 2 ) ;
446
+ expect ( submitSpy ) . toHaveBeenCalledTimes ( 1 ) ;
447
+ } ) ;
409
448
it ( "should not tolerate mixture of FSUM9195 and other FSUM messages" , async ( ) => {
410
449
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
411
450
stdoutHandler ( "Injected FSUM9195 and FSUM9196 error message" ) ;
451
+ return 1 ;
412
452
} ) ;
413
453
414
454
await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , true ,
@@ -594,6 +634,7 @@ describe("BundlePusher01", () => {
594
634
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
595
635
if ( cmd . indexOf ( "npm install" ) > - 1 ) {
596
636
stdoutHandler ( "Injected stdout error message" ) ;
637
+ return 1 ;
597
638
}
598
639
else {
599
640
return true ;
@@ -626,6 +667,7 @@ describe("BundlePusher01", () => {
626
667
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
627
668
if ( cmd . indexOf ( "npm install" ) > - 1 ) {
628
669
stdoutHandler ( "Injected FSUM7351 not found message" ) ;
670
+ return 1 ;
629
671
}
630
672
else {
631
673
return true ;
@@ -658,6 +700,7 @@ describe("BundlePusher01", () => {
658
700
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
659
701
if ( cmd . indexOf ( "npm install" ) > - 1 ) {
660
702
stdoutHandler ( "Injected npm ERR! Exit status 1 message" ) ;
703
+ return 1 ;
661
704
}
662
705
else {
663
706
return true ;
@@ -725,6 +768,7 @@ describe("BundlePusher01", () => {
725
768
parms . arguments . targetdir = "//u//escapedDirName" ;
726
769
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
727
770
stdoutHandler ( "Injected stdout shell message" ) ;
771
+ return 0 ;
728
772
} ) ;
729
773
readdirSpy . mockImplementation ( ( data : string ) => {
730
774
return [ "package.json" ] ;
@@ -752,6 +796,7 @@ describe("BundlePusher01", () => {
752
796
parms . arguments . targetdir = "//u//escapedDirName" ;
753
797
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
754
798
stdoutHandler ( "Injected stdout shell message for " + dir ) ;
799
+ return 0 ;
755
800
} ) ;
756
801
readdirSpy . mockImplementation ( ( data : string ) => {
757
802
if ( data . endsWith ( "XXXDIRXXX" ) ) {
@@ -799,6 +844,7 @@ describe("BundlePusher01", () => {
799
844
parms . arguments . verbose = true ;
800
845
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
801
846
stdoutHandler ( "Injected stdout shell message" ) ;
847
+ return 0 ;
802
848
} ) ;
803
849
readdirSpy . mockImplementation ( ( data : string ) => {
804
850
return [ "package.json" ] ;
@@ -832,6 +878,7 @@ describe("BundlePusher01", () => {
832
878
parms . arguments . verbose = true ;
833
879
shellSpy . mockImplementation ( ( session : any , cmd : string , dir : string , stdoutHandler : ( data : string ) => void ) => {
834
880
stdoutHandler ( "Injected stdout shell message" ) ;
881
+ return 0 ;
835
882
} ) ;
836
883
readdirSpy . mockImplementation ( ( data : string ) => {
837
884
return [ "package.json" ] ;
0 commit comments