Skip to content

Commit f986937

Browse files
committed
test tweaks
1 parent edde157 commit f986937

File tree

4 files changed

+113
-66
lines changed

4 files changed

+113
-66
lines changed

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 91 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
5656

5757
describe("BundleDeployer01", () => {
5858

59+
afterEach(() => {
60+
jest.resetAllMocks();
61+
});
5962
it("should complain with missing zOSMF profile for deploy", async () => {
6063
await runDeployTestWithError();
6164
});
@@ -64,98 +67,146 @@ describe("BundleDeployer01", () => {
6467
});
6568
it("should complain if cicshlq not found", async () => {
6669

67-
jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
70+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
71+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => { throw new Error( "Injected CICSHLQ error" ); });
6872
await runDeployTestWithError();
73+
74+
expect(createSpy).toHaveBeenCalledTimes(1);
75+
expect(listSpy).toHaveBeenCalledTimes(1);
6976
});
7077
it("should complain if cicshlq not found2", async () => {
7178

72-
jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
73-
jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val1: "wibble"}));
79+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
80+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val1: "wibble"}));
7481
await runDeployTestWithError();
82+
83+
expect(createSpy).toHaveBeenCalledTimes(1);
84+
expect(listSpy).toHaveBeenCalledTimes(1);
7585
});
7686
it("should complain if cpsmhlq not found", async () => {
7787

78-
jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
79-
jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val1: "DFHDPLOY"}));
88+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
89+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val1: "DFHDPLOY"}))
90+
.mockImplementationOnce(() => { throw new Error( "Injected CPSMHLQ error" ); });
8091
await runDeployTestWithError();
92+
93+
expect(createSpy).toHaveBeenCalledTimes(1);
94+
expect(listSpy).toHaveBeenCalledTimes(2);
8195
});
8296
it("should complain if cpsmhlq not found2", async () => {
8397

84-
jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
85-
jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
86-
.mockImplementationOnce(() => ( { val: "wibble" }));
98+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
99+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
100+
.mockImplementationOnce(() => ( { val: "wibble" }));
87101
await runDeployTestWithError();
102+
103+
expect(createSpy).toHaveBeenCalledTimes(1);
104+
expect(listSpy).toHaveBeenCalledTimes(2);
88105
});
89106
it("should handle failure during submitjobs processing", async () => {
90107

91-
const spy1 = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
92-
const spy2 = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
93-
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
108+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
109+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
110+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
111+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() => { throw new Error( "Injected Submit error" ); });
94112
await runDeployTestWithError();
113+
114+
expect(createSpy).toHaveBeenCalledTimes(1);
115+
expect(listSpy).toHaveBeenCalledTimes(2);
116+
expect(submitSpy).toHaveBeenCalledTimes(1);
95117
});
96-
it("should complain of SYSTSPRT not found", async () => {
118+
it("should complain if SYSTSPRT not found", async () => {
97119

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(() => [{}] );
120+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
121+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
122+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
123+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() => [{}] );
102124
await runDeployTestWithError();
125+
126+
expect(createSpy).toHaveBeenCalledTimes(1);
127+
expect(listSpy).toHaveBeenCalledTimes(2);
128+
expect(submitSpy).toHaveBeenCalledTimes(1);
103129
});
104130
it("should tolerate empty output from DFHDPLOY", async () => {
105131

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"}] );
132+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
133+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
134+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
135+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
136+
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY"}] );
110137
await runDeployTestWithError();
138+
139+
expect(createSpy).toHaveBeenCalledTimes(1);
140+
expect(listSpy).toHaveBeenCalledTimes(2);
141+
expect(submitSpy).toHaveBeenCalledTimes(1);
111142
});
112143
it("should complain if status can't be determined", async () => {
113144

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(() =>
145+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
146+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
147+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
148+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
118149
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: " "}] );
119150
await runDeployTestWithError();
151+
152+
expect(createSpy).toHaveBeenCalledTimes(1);
153+
expect(listSpy).toHaveBeenCalledTimes(2);
154+
expect(submitSpy).toHaveBeenCalledTimes(1);
120155
});
121156
it("should complain if DFHDPLOY ends with an error", async () => {
122157

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(() =>
158+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
159+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
160+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
161+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
127162
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2055I"}] );
128163
await runDeployTestWithError();
164+
165+
expect(createSpy).toHaveBeenCalledTimes(1);
166+
expect(listSpy).toHaveBeenCalledTimes(2);
167+
expect(submitSpy).toHaveBeenCalledTimes(1);
129168
});
130169
it("should complete with warnings ", async () => {
131170

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(() =>
171+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
172+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
173+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
174+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
136175
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2043I"}] );
137176

138177
await runDeployTest();
178+
179+
expect(createSpy).toHaveBeenCalledTimes(1);
180+
expect(listSpy).toHaveBeenCalledTimes(2);
181+
expect(submitSpy).toHaveBeenCalledTimes(1);
139182
});
140183
it("should deploy successfully", async () => {
141184

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(() =>
185+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
186+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
187+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
188+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
146189
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I"}] );
147190

148191
await runDeployTest();
192+
193+
expect(createSpy).toHaveBeenCalledTimes(1);
194+
expect(listSpy).toHaveBeenCalledTimes(2);
195+
expect(submitSpy).toHaveBeenCalledTimes(1);
149196
});
150197
it("should undeploy successfully", async () => {
151198

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(() =>
199+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => ({}));
200+
const listSpy = jest.spyOn(List, "allMembers").mockImplementationOnce(() => ( { val: "DFHDPLOY" }))
201+
.mockImplementationOnce(() => ( { val: "EYU9ABSI" }));
202+
const submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementationOnce(() =>
156203
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2037I"}] );
157204

158205
await runUndeployTest();
206+
207+
expect(createSpy).toHaveBeenCalledTimes(1);
208+
expect(listSpy).toHaveBeenCalledTimes(2);
209+
expect(submitSpy).toHaveBeenCalledTimes(1);
159210
});
160211
it("should generate deploy JCL with neither csdgroup nor resgroup", async () => {
161212

__tests__/api/BundleDeploy/__snapshots__/BundleDeployer.test.ts.snap

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 1`] = `"DFHRL2055I"`;
3+
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 1`] = `"DFHDPLOY stopped processing due to an error."`;
44

5-
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 2`] = `"DFHDPLOY stopped processing due to an error."`;
5+
exports[`BundleDeployer01 should complain if SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
66

7-
exports[`BundleDeployer01 should complain if cicshlq not found 1`] = `"Validation of --cicshlq dataset failed: Cannot read property 'hostname' of undefined"`;
7+
exports[`BundleDeployer01 should complain if cicshlq not found 1`] = `"Validation of --cicshlq dataset failed: Injected CICSHLQ error"`;
88

99
exports[`BundleDeployer01 should complain if cicshlq not found2 1`] = `"DFHDPLOY not found in SDFHLOAD within the --cicshlq dataset: 12345678901234567890123456789012345.SDFHLOAD"`;
1010

11-
exports[`BundleDeployer01 should complain if cpsmhlq not found 1`] = `"Validation of --cpsmhlq dataset failed: Cannot read property 'hostname' of undefined"`;
11+
exports[`BundleDeployer01 should complain if cpsmhlq not found 1`] = `"Validation of --cpsmhlq dataset failed: Injected CPSMHLQ error"`;
1212

1313
exports[`BundleDeployer01 should complain if cpsmhlq not found2 1`] = `"EYU9ABSI not found in SEYUAUTH within the --cpsmhlq dataset: abcde12345abcde12345abcde12345abcde.SEYUAUTH"`;
1414

15-
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `" "`;
16-
17-
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed, but status cannot be determined."`;
18-
19-
exports[`BundleDeployer01 should complain of SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
15+
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `"DFHDPLOY command completed, but status cannot be determined."`;
2016

2117
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
2218

2319
exports[`BundleDeployer01 should complain with missing zOSMF profile for undeploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
2420

25-
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHRL2043I"`;
26-
27-
exports[`BundleDeployer01 should complete with warnings 2`] = `"DFHDPLOY completed with warnings."`;
21+
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHDPLOY completed with warnings."`;
2822

2923
exports[`BundleDeployer01 should deploy successfully 1`] = `"Bundle deployment successful."`;
3024

@@ -365,7 +359,7 @@ UNDEPLOY BUNDLE(12345678)
365359
"
366360
`;
367361

368-
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL: 'Cannot read property 'hostname' of undefined'. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
362+
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL: 'Injected Submit error'. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
369363

370364
exports[`BundleDeployer01 should support long bundledir 1`] = `
371365
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
@@ -509,9 +503,7 @@ UNDEPLOY BUNDLE(12345678)
509503
"
510504
`;
511505

512-
exports[`BundleDeployer01 should support verbose=true output for deploy 1`] = `"DFHRL2012I"`;
513-
514-
exports[`BundleDeployer01 should support verbose=true output for deploy 2`] = `
506+
exports[`BundleDeployer01 should support verbose=true output for deploy 1`] = `
515507
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
516508
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
517509
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD
@@ -530,9 +522,7 @@ DEPLOY BUNDLE(12345678)
530522
"
531523
`;
532524

533-
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `"DFHRL2037I"`;
534-
535-
exports[`BundleDeployer01 should support verbose=true output for undeploy 2`] = `
525+
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `
536526
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
537527
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
538528
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD

docs/tutorials/cics-deploy/CICSDeployPlugin.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Before you begin, [set up](../Setup.md) your environment to install a plug-in.
55
## Overview
66
This tutorial covers installing and running this bundled Zowe CLI cics-deploy plugin as-is (without modification).
77

8-
The plug-in adds a command to the CLI that supports generation and deployment of CICS Bundle resources from the current directory of your PC.
8+
The plug-in adds a command to the CLI that supports generation and deployment of CICS bundle resources from the current directory of your PC.
99

1010
## Installing the cics-deploy plug-in to Zowe CLI
1111

@@ -18,11 +18,14 @@ Issue the following commands to install the cics-deploy plug-in to Zowe CLI:
1818
2. `zowe plugins install ./zowe-cli-cics-deploy-plugin`
1919

2020
## Viewing the installed plug-in help
21-
Issue `zowe cics-deploy generate deploy --help` in the command line to return information for the installed `cics-deploy` command group.
21+
Issue `zowe cics-deploy --help` in the command line to return information for the installed `cics-deploy` command group. Information for
22+
specific cics-deploy commands can also be displayed, for example `zowe cics-deploy generate bundle --help` will return information
23+
on generating a CICS bundle.
2224

2325
## Using the installed plug-in
24-
To use the plug-in functionality, issue: `zowe cics-deploy generate bundle`. It will generate meta-data for a simple CICS Bundle into the working directory;
25-
if the working directory contains a node.js `package.json` file then a NODEJSAPP resource definition will be included in the Bundle meta-data.
26+
To use the plug-in functionality, issue: `zowe cics-deploy generate bundle`. It will generate meta-data for a simple CICS bundle into the working directory;
27+
if the working directory contains a node.js `package.json` file then a NODEJSAPP resource definition will be included in the bundle meta-data. Other
28+
commands such as `zowe cics-deploy deploy bundle` can be issued if required.
2629

2730
## Testing the installed plug-in
2831
To run automated tests against the plug-in, `cd` into your `cics-deploy/zowe-cli-cics-deploy-plugin` folder.

src/api/BundleDeploy/BundleDeployer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,16 @@ export class BundleDeployer {
245245
// we're looking for the SYSTSPRT output from the DFHDPLOY step.
246246
if (file.ddName === "SYSTSPRT" && file.stepName === "DFHDPLOY") {
247247

248-
// log the full output for serviceability to the log
249-
const logger = Logger.getAppLogger();
250248
if (file.data === undefined || file.data.length === 0) {
251249
status.stageName = TaskStage.FAILED;
252250
throw new Error("DFHDPLOY did not generate any output. Most recent status update: '" + status.statusMessage + "'.");
253251
}
254-
logger.debug(file.data);
252+
253+
// log the full output for serviceability to the log
254+
if (this.params.arguments.silent === undefined) {
255+
const logger = Logger.getAppLogger();
256+
logger.debug(file.data);
257+
}
255258

256259
// Finish the progress bar
257260
status.statusMessage = "Completed DFHDPLOY";

0 commit comments

Comments
 (0)