@@ -57,98 +57,141 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
57
57
describe ( "BundleDeployer01" , ( ) => {
58
58
59
59
it ( "should complain with missing zOSMF profile for deploy" , async ( ) => {
60
+ await runDeployTestWithError ( ) ;
61
+ } ) ;
62
+ it ( "should complain with missing zOSMF profile for undeploy" , async ( ) => {
63
+ await runUndeployTestWithError ( ) ;
64
+ } ) ;
65
+ it ( "should complain if cicshlq not found" , async ( ) => {
60
66
61
- let parms : IHandlerParameters ;
62
- parms = DEFAULT_PARAMTERS ;
63
- setCommonParmsForDeployTests ( parms ) ;
64
- parms . arguments . csdgroup = "12345678" ;
67
+ jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
68
+ await runDeployTestWithError ( ) ;
69
+ } ) ;
70
+ it ( "should complain if cicshlq not found2" , async ( ) => {
65
71
66
- // Create a Bundle
67
- const bd = new BundleDeployer ( parms ) ;
72
+ jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
73
+ jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val1 : "wibble" } ) ) ;
74
+ await runDeployTestWithError ( ) ;
75
+ } ) ;
76
+ it ( "should complain if cpsmhlq not found" , async ( ) => {
68
77
69
- let err : Error ;
70
- try {
71
- const response = await bd . deployBundle ( ) ;
72
- } catch ( e ) {
73
- err = e ;
74
- }
75
- expect ( err ) . toBeDefined ( ) ;
76
- expect ( err . message ) . toMatchSnapshot ( ) ;
78
+ jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
79
+ jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val1 : "DFHDPLOY" } ) ) ;
80
+ await runDeployTestWithError ( ) ;
77
81
} ) ;
78
- it ( "should complain with missing zOSMF profile for undeploy " , async ( ) => {
82
+ it ( "should complain if cpsmhlq not found2 " , async ( ) => {
79
83
80
- let parms : IHandlerParameters ;
81
- parms = DEFAULT_PARAMTERS ;
82
- setCommonParmsForDeployTests ( parms ) ;
83
- parms . arguments . csdgroup = "12345678" ;
84
+ jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
85
+ jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
86
+ . mockImplementationOnce ( ( ) => ( { val : "wibble" } ) ) ;
87
+ await runDeployTestWithError ( ) ;
88
+ } ) ;
89
+ it ( "should handle failure during submitjobs processing" , async ( ) => {
84
90
85
- // Create a Bundle
86
- const bd = new BundleDeployer ( parms ) ;
91
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
92
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
93
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
94
+ await runDeployTestWithError ( ) ;
95
+ } ) ;
96
+ it ( "should complain of SYSTSPRT not found" , async ( ) => {
87
97
88
- let err : Error ;
89
- try {
90
- const response = await bd . undeployBundle ( ) ;
91
- } catch ( e ) {
92
- err = e ;
93
- }
94
- expect ( err ) . toBeDefined ( ) ;
95
- expect ( err . message ) . toMatchSnapshot ( ) ;
98
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
99
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
100
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
101
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) => [ { } ] ) ;
102
+ await runDeployTestWithError ( ) ;
96
103
} ) ;
97
- it ( "should generate deploy JCL for csdgroup" , ( ) => {
104
+ it ( "should tolerate empty output from DFHDPLOY" , async ( ) => {
105
+
106
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
107
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
108
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
109
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) => [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" } ] ) ;
110
+ await runDeployTestWithError ( ) ;
111
+ } ) ;
112
+ it ( "should complain if status can't be determined" , async ( ) => {
113
+
114
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
115
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
116
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
117
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
118
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : " " } ] ) ;
119
+ await runDeployTestWithError ( ) ;
120
+ } ) ;
121
+ it ( "should complain if DFHDPLOY ends with an error" , async ( ) => {
122
+
123
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
124
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
125
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
126
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
127
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2055I" } ] ) ;
128
+ await runDeployTestWithError ( ) ;
129
+ } ) ;
130
+ it ( "should complete with warnings " , async ( ) => {
131
+
132
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
133
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
134
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
135
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
136
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2043I" } ] ) ;
137
+
138
+ await runDeployTest ( ) ;
139
+ } ) ;
140
+ it ( "should deploy successfully" , async ( ) => {
141
+
142
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
143
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
144
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
145
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
146
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2012I" } ] ) ;
147
+
148
+ await runDeployTest ( ) ;
149
+ } ) ;
150
+ it ( "should undeploy successfully" , async ( ) => {
151
+
152
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
153
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
154
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
155
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
156
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2037I" } ] ) ;
157
+
158
+ await runUndeployTest ( ) ;
159
+ } ) ;
160
+ it ( "should generate deploy JCL for csdgroup" , async ( ) => {
98
161
99
162
let parms : IHandlerParameters ;
100
163
parms = DEFAULT_PARAMTERS ;
101
164
setCommonParmsForDeployTests ( parms ) ;
102
165
parms . arguments . csdgroup = "12345678" ;
103
-
104
- // Create a Bundle
105
- const bd = new BundleDeployer ( parms ) ;
106
-
107
- // Check the output as JSON
108
- expect ( bd . getDeployJCL ( ) ) . toMatchSnapshot ( ) ;
166
+ await testDeployJCL ( parms ) ;
109
167
} ) ;
110
- it ( "should generate deploy JCL for csdgroup with timeout" , ( ) => {
168
+ it ( "should generate deploy JCL for csdgroup with timeout" , async ( ) => {
111
169
112
170
let parms : IHandlerParameters ;
113
171
parms = DEFAULT_PARAMTERS ;
114
172
setCommonParmsForDeployTests ( parms ) ;
115
173
parms . arguments . csdgroup = "12345678" ;
116
174
parms . arguments . timeout = 1500 ;
117
-
118
- // Create a Bundle
119
- const bd = new BundleDeployer ( parms ) ;
120
-
121
- // Check the output as JSON
122
- expect ( bd . getDeployJCL ( ) ) . toMatchSnapshot ( ) ;
175
+ await testDeployJCL ( parms ) ;
123
176
} ) ;
124
- it ( "should generate deploy JCL for resgroup" , ( ) => {
177
+ it ( "should generate deploy JCL for resgroup" , async ( ) => {
125
178
126
179
let parms : IHandlerParameters ;
127
180
parms = DEFAULT_PARAMTERS ;
128
181
setCommonParmsForDeployTests ( parms ) ;
129
182
parms . arguments . resgroup = "12345678" ;
130
-
131
- // Create a Bundle
132
- const bd = new BundleDeployer ( parms ) ;
133
-
134
- // Check the output as JSON
135
- expect ( bd . getDeployJCL ( ) ) . toMatchSnapshot ( ) ;
183
+ await testDeployJCL ( parms ) ;
136
184
} ) ;
137
- it ( "should generate deploy JCL for resgroup with timeout" , ( ) => {
185
+ it ( "should generate deploy JCL for resgroup with timeout" , async ( ) => {
138
186
139
187
let parms : IHandlerParameters ;
140
188
parms = DEFAULT_PARAMTERS ;
141
189
setCommonParmsForDeployTests ( parms ) ;
142
190
parms . arguments . resgroup = "12345678" ;
143
191
parms . arguments . timeout = 1500 ;
144
-
145
- // Create a Bundle
146
- const bd = new BundleDeployer ( parms ) ;
147
-
148
- // Check the output as JSON
149
- expect ( bd . getDeployJCL ( ) ) . toMatchSnapshot ( ) ;
192
+ await testDeployJCL ( parms ) ;
150
193
} ) ;
151
- it ( "should support long bundledir" , ( ) => {
194
+ it ( "should support long bundledir" , async ( ) => {
152
195
153
196
let parms : IHandlerParameters ;
154
197
parms = DEFAULT_PARAMTERS ;
@@ -159,70 +202,108 @@ describe("BundleDeployer01", () => {
159
202
"12345678901234567890123456789012345678901234567890" +
160
203
"12345678901234567890123456789012345678901234567890" +
161
204
"1234567890123456789012345678901234567890123456789012345" ;
162
-
163
- // Create a Bundle
164
- const bd = new BundleDeployer ( parms ) ;
165
-
166
- // Check the output as JSON
167
- expect ( bd . getDeployJCL ( ) ) . toMatchSnapshot ( ) ;
205
+ await testDeployJCL ( parms ) ;
168
206
} ) ;
169
- it ( "should generate undeploy JCL for csdgroup" , ( ) => {
207
+ it ( "should generate undeploy JCL for csdgroup" , async ( ) => {
170
208
171
209
let parms : IHandlerParameters ;
172
210
parms = DEFAULT_PARAMTERS ;
173
211
setCommonParmsForDeployTests ( parms ) ;
174
212
parms . arguments . csdgroup = "12345678" ;
175
-
176
- // Create a Bundle
177
- const bd = new BundleDeployer ( parms ) ;
178
-
179
- // Check the output as JSON
180
- expect ( bd . getUndeployJCL ( ) ) . toMatchSnapshot ( ) ;
213
+ await testUndeployJCL ( parms ) ;
181
214
} ) ;
182
- it ( "should generate undeploy JCL for csdgroup with timeout" , ( ) => {
215
+ it ( "should generate undeploy JCL for csdgroup with timeout" , async ( ) => {
183
216
184
217
let parms : IHandlerParameters ;
185
218
parms = DEFAULT_PARAMTERS ;
186
219
setCommonParmsForDeployTests ( parms ) ;
187
220
parms . arguments . csdgroup = "12345678" ;
188
221
parms . arguments . timeout = 1500 ;
189
-
190
- // Create a Bundle
191
- const bd = new BundleDeployer ( parms ) ;
192
-
193
- // Check the output as JSON
194
- expect ( bd . getUndeployJCL ( ) ) . toMatchSnapshot ( ) ;
222
+ await testUndeployJCL ( parms ) ;
195
223
} ) ;
196
- it ( "should generate undeploy JCL for resgroup" , ( ) => {
224
+ it ( "should generate undeploy JCL for resgroup" , async ( ) => {
197
225
198
226
let parms : IHandlerParameters ;
199
227
parms = DEFAULT_PARAMTERS ;
200
228
setCommonParmsForDeployTests ( parms ) ;
201
229
parms . arguments . resgroup = "12345678" ;
202
-
203
- // Create a Bundle
204
- const bd = new BundleDeployer ( parms ) ;
205
-
206
- // Check the output as JSON
207
- expect ( bd . getUndeployJCL ( ) ) . toMatchSnapshot ( ) ;
230
+ await testUndeployJCL ( parms ) ;
208
231
} ) ;
209
- it ( "should generate undeploy JCL for resgroup with timeout" , ( ) => {
232
+ it ( "should generate undeploy JCL for resgroup with timeout" , async ( ) => {
210
233
211
234
let parms : IHandlerParameters ;
212
235
parms = DEFAULT_PARAMTERS ;
213
236
setCommonParmsForDeployTests ( parms ) ;
214
237
parms . arguments . resgroup = "12345678" ;
215
238
parms . arguments . timeout = 1500 ;
216
-
217
- // Create a Bundle
218
- const bd = new BundleDeployer ( parms ) ;
219
-
220
- // Check the output as JSON
221
- expect ( bd . getUndeployJCL ( ) ) . toMatchSnapshot ( ) ;
239
+ await testUndeployJCL ( parms ) ;
222
240
} ) ;
223
241
} ) ;
224
242
243
+ async function runDeployTestWithError ( ) {
244
+ let parms : IHandlerParameters ;
245
+ parms = DEFAULT_PARAMTERS ;
246
+ setCommonParmsForDeployTests ( parms ) ;
247
+ parms . arguments . csdgroup = "12345678" ;
248
+
249
+ const bd = new BundleDeployer ( parms ) ;
250
+
251
+ let err : Error ;
252
+ try {
253
+ const response = await bd . deployBundle ( ) ;
254
+ } catch ( e ) {
255
+ err = e ;
256
+ }
257
+ expect ( err ) . toBeDefined ( ) ;
258
+ expect ( err . message ) . toMatchSnapshot ( ) ;
259
+ }
260
+
261
+ async function runUndeployTestWithError ( ) {
262
+ let parms : IHandlerParameters ;
263
+ parms = DEFAULT_PARAMTERS ;
264
+ setCommonParmsForUndeployTests ( parms ) ;
265
+ parms . arguments . csdgroup = "12345678" ;
266
+
267
+ const bd = new BundleDeployer ( parms ) ;
268
+
269
+ let err : Error ;
270
+ try {
271
+ const response = await bd . undeployBundle ( ) ;
272
+ } catch ( e ) {
273
+ err = e ;
274
+ }
275
+ expect ( err ) . toBeDefined ( ) ;
276
+ expect ( err . message ) . toMatchSnapshot ( ) ;
277
+ }
278
+
279
+ async function runDeployTest ( ) {
280
+ let parms : IHandlerParameters ;
281
+ parms = DEFAULT_PARAMTERS ;
282
+ setCommonParmsForDeployTests ( parms ) ;
283
+ parms . arguments . csdgroup = "12345678" ;
284
+
285
+ const bd = new BundleDeployer ( parms ) ;
286
+ const response = await bd . deployBundle ( ) ;
287
+ expect ( response ) . toMatchSnapshot ( ) ;
288
+ }
289
+
290
+ async function runUndeployTest ( ) {
291
+ let parms : IHandlerParameters ;
292
+ parms = DEFAULT_PARAMTERS ;
293
+ setCommonParmsForUndeployTests ( parms ) ;
294
+ parms . arguments . csdgroup = "12345678" ;
295
+
296
+ const bd = new BundleDeployer ( parms ) ;
297
+ const response = await bd . undeployBundle ( ) ;
298
+ expect ( response ) . toMatchSnapshot ( ) ;
299
+ }
300
+
225
301
function setCommonParmsForDeployTests ( parms : IHandlerParameters ) {
302
+ setCommonParmsForUndeployTests ( parms ) ;
303
+ parms . arguments . bundledir = "1234567890" ;
304
+ }
305
+
306
+ function setCommonParmsForUndeployTests ( parms : IHandlerParameters ) {
226
307
parms . arguments . cicshlq = "12345678901234567890123456789012345" ;
227
308
parms . arguments . cpsmhlq = "abcde12345abcde12345abcde12345abcde" ;
228
309
parms . arguments . cicsplex = "12345678" ;
@@ -231,6 +312,32 @@ function setCommonParmsForDeployTests(parms: IHandlerParameters) {
231
312
parms . arguments . resgroup = undefined ;
232
313
parms . arguments . timeout = undefined ;
233
314
parms . arguments . name = "12345678" ;
234
- parms . arguments . bundledir = "1234567890" ;
235
315
}
236
316
317
+ async function testDeployJCL ( parms : IHandlerParameters ) {
318
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
319
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
320
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
321
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
322
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2037I" } ] ) ;
323
+
324
+ const bd = new BundleDeployer ( parms ) ;
325
+ const response = await bd . deployBundle ( ) ;
326
+
327
+ // Check the generated JCL
328
+ expect ( spy3 . mock . calls [ spy3 . mock . calls . length - 1 ] [ 1 ] ) . toMatchSnapshot ( ) ;
329
+ }
330
+
331
+ async function testUndeployJCL ( parms : IHandlerParameters ) {
332
+ const spy1 = jest . spyOn ( ZosmfSession , "createBasicZosmfSession" ) . mockImplementationOnce ( ( ) => ( { } ) ) ;
333
+ const spy2 = jest . spyOn ( List , "allMembers" ) . mockImplementationOnce ( ( ) => ( { val : "DFHDPLOY" } ) )
334
+ . mockImplementationOnce ( ( ) => ( { val : "EYU9ABSI" } ) ) ;
335
+ const spy3 = jest . spyOn ( SubmitJobs , "submitJclString" ) . mockImplementationOnce ( ( ) =>
336
+ [ { ddName : "SYSTSPRT" , stepName : "DFHDPLOY" , data : "DFHRL2037I" } ] ) ;
337
+
338
+ const bd = new BundleDeployer ( parms ) ;
339
+ const response = await bd . undeployBundle ( ) ;
340
+
341
+ // Check the generated JCL
342
+ expect ( spy3 . mock . calls [ spy3 . mock . calls . length - 1 ] [ 1 ] ) . toMatchSnapshot ( ) ;
343
+ }
0 commit comments