Skip to content

Commit 7957551

Browse files
Merge pull request #66 from pcoop/branch1
Initial implementation of 'push bundle'
2 parents f956268 + 4ef7056 commit 7957551

26 files changed

+1269
-15331
lines changed

__tests__/__system__/cli/generate/cli.generate.bundle.system.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("cics-deploy generate bundle", () => {
4646
fse.removeSync(TEST_APPS_DIR);
4747
}
4848
fse.mkdirSync(TEST_APPS_DIR);
49-
fse.copySync(__dirname + "../../../../__resources__/apps", TEST_APPS_DIR);
49+
fse.copySync(__dirname + "/../../../__resources__/apps", TEST_APPS_DIR);
5050
});
5151

5252
it("should generate a bundle using defaults from package.json", async () => {

__tests__/api/BundleContent/BundleMocked.test.ts

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@ describe("MockedFilesystemTests", () => {
2424
const parser = require("xml2json");
2525
});
2626

27-
it("should complain if exceptions are thrown during manifest parsing", () => {
28-
29-
jest.spyOn(JSON, "parse").mockImplementationOnce(() => { throw new Error("Wibble"); });
30-
31-
let err: Error;
32-
try {
33-
const bund = new Bundle("__tests__/__resources__/ExampleBundle01", true, true);
34-
}
35-
catch (error) {
36-
err = error;
37-
}
38-
39-
expect(err).toBeDefined();
40-
expect(err.message).toContain("Parsing error occurred reading a CICS manifest file: Wibble");
41-
});
42-
4327
it("should tolerate META-INF directory not existing", () => {
4428
// Mocks for the manifest - META-INF exists
4529
jest.spyOn(fs, "existsSync").mockImplementationOnce(() => ( false ));
@@ -534,4 +518,51 @@ describe("MockedFilesystemTests", () => {
534518
expect(err.message).toContain(".zosattributes'");
535519
expect(err.message).toContain("InjectedError");
536520
});
521+
it("should know if the bundle is valid", () => {
522+
jest.spyOn(fs, "accessSync").mockReturnValue(true);
523+
jest.spyOn(fs, "existsSync").mockReturnValue(false);
524+
jest.spyOn(fs, "writeFileSync").mockReturnValue(true);
525+
jest.spyOn(fs, "mkdirSync").mockReturnValue(true);
526+
527+
let err: Error;
528+
let bund;
529+
try {
530+
bund = new Bundle("__tests__/__resources__/ExampleBundle01", false, false);
531+
bund.validate();
532+
}
533+
catch (error) {
534+
err = error;
535+
}
536+
537+
expect(err).toBeDefined();
538+
expect(err.message).toContain("No bundle manifest file found");
539+
expect(err.message).toContain("cics.xml");
540+
541+
err = undefined;
542+
try {
543+
bund.save();
544+
bund.validate();
545+
}
546+
catch (error) {
547+
err = error;
548+
}
549+
550+
expect(err).toBeUndefined();
551+
});
552+
553+
it("should complain if exceptions are thrown during manifest parsing", () => {
554+
555+
jest.spyOn(JSON, "parse").mockImplementationOnce(() => { throw new Error("Wibble"); });
556+
557+
let err: Error;
558+
try {
559+
const bund = new Bundle("__tests__/__resources__/ExampleBundle01", true, true);
560+
}
561+
catch (error) {
562+
err = error;
563+
}
564+
565+
expect(err).toBeDefined();
566+
expect(err.message).toContain("Parsing error occurred reading a CICS manifest file: Wibble");
567+
});
537568
});

__tests__/api/BundleContent/BundleSimple.test.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as fs from "fs";
1414

1515
describe("Bundle01", () => {
1616
afterEach(() => {
17-
jest.resetAllMocks();
17+
jest.restoreAllMocks();
1818
});
1919
it("should read an existing bundle", () => {
2020

@@ -204,4 +204,39 @@ describe("Bundle01", () => {
204204
// Check the output as JSON
205205
expect(JSON.stringify(bund.getManifest())).toMatchSnapshot();
206206
});
207+
it("should find a directory within the Bundle", () => {
208+
209+
// Create a Bundle
210+
const bund = new Bundle("__tests__/__resources__/ExampleBundle02", true, true);
211+
212+
expect(bund.contains("META-INF")).toBeTruthy();
213+
});
214+
it("should find a file within the Bundle", () => {
215+
216+
// Create a Bundle
217+
const bund = new Bundle("__tests__/__resources__/ExampleBundle02", true, true);
218+
219+
expect(bund.contains("Artefact2.txt")).toBeTruthy();
220+
});
221+
it("should find a file within a directory within the Bundle", () => {
222+
223+
// Create a Bundle
224+
const bund = new Bundle("__tests__/__resources__/ExampleBundle02", true, true);
225+
226+
expect(bund.contains("META-INF/cics.xml")).toBeTruthy();
227+
});
228+
it("should not find a missing file within the Bundle", () => {
229+
230+
// Create a Bundle
231+
const bund = new Bundle("__tests__/__resources__/ExampleBundle02", true, true);
232+
233+
expect(bund.contains("doesNotexist")).toBeFalsy();
234+
});
235+
it("should not find a file outside of the Bundle", () => {
236+
237+
// Create a Bundle
238+
const bund = new Bundle("__tests__/__resources__/ExampleBundle02", true, true);
239+
240+
expect(bund.contains("../ExampleBundle01")).toBeFalsy();
241+
});
207242
});

__tests__/api/BundleContent/Manifest.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe("Manifest01", () => {
169169
}
170170

171171
// Check the output as JSON
172-
expect(err.message).toMatchSnapshot();
172+
expect(err.message).toContain("Existing CICS Manifest file found with unparsable content.");
173173
});
174174
it("Parse a manifest with bad namespace", () => {
175175

@@ -183,7 +183,7 @@ describe("Manifest01", () => {
183183
}
184184

185185
// Check the output as JSON
186-
expect(err.message).toMatchSnapshot();
186+
expect(err.message).toContain("Existing CICS Manifest file found with unexpected namespace: wibble .");
187187
});
188188
it("Parse a malformed manifest", () => {
189189

@@ -197,6 +197,6 @@ describe("Manifest01", () => {
197197
}
198198

199199
// Check the output as JSON
200-
expect(err.message).toMatchSnapshot();
200+
expect(err.message).toContain("Existing CICS Manifest file found with unparsable content.");
201201
});
202202
});

__tests__/api/BundleContent/__snapshots__/Manifest.test.ts.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Manifest01 Parse a garbage manifest 1`] = `"Existing CICS Manifest file found with unparsable content."`;
4-
5-
exports[`Manifest01 Parse a malformed manifest 1`] = `"Existing CICS Manifest file found with unparsable content."`;
6-
7-
exports[`Manifest01 Parse a manifest with bad namespace 1`] = `"Existing CICS Manifest file found with unexpected namespace: wibble ."`;
8-
93
exports[`Manifest01 set a long bundleId 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"1234567890123456789012345678901234567890123456789012345678901234\\",\\"bundleMajorVer\\":\\"10\\",\\"bundleMinorVer\\":\\"11\\",\\"bundleMicroVer\\":\\"12\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"path1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"path2\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"}]}}"`;
104

115
exports[`Manifest01 set a long bundleId 2`] = `"1234567890123456789012345678901234567890123456789012345678901234"`;

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
5757
describe("BundleDeployer01", () => {
5858

5959
afterEach(() => {
60-
jest.resetAllMocks();
60+
jest.restoreAllMocks();
6161
});
6262
it("should complain with missing zOSMF profile for deploy", async () => {
63+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => { throw new Error( "Injected Create error" ); });
6364
await runDeployTestWithError();
65+
66+
expect(createSpy).toHaveBeenCalledTimes(1);
6467
});
6568
it("should complain with missing zOSMF profile for undeploy", async () => {
69+
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => { throw new Error( "Injected Create error" ); });
6670
await runUndeployTestWithError();
71+
72+
expect(createSpy).toHaveBeenCalledTimes(1);
6773
});
6874
it("should complain if cicshlq not found", async () => {
6975

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

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

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

79
exports[`BundleDeployer01 should complain if cicshlq not found 1`] = `"Validation of --cicshlq dataset failed: Injected CICSHLQ error"`;
810

@@ -12,13 +14,17 @@ exports[`BundleDeployer01 should complain if cpsmhlq not found 1`] = `"Validatio
1214

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

15-
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `"DFHDPLOY command completed, but status cannot be determined."`;
17+
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `" "`;
18+
19+
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed, but status cannot be determined."`;
20+
21+
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Injected Create error"`;
1622

17-
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
23+
exports[`BundleDeployer01 should complain with missing zOSMF profile for undeploy 1`] = `"Injected Create error"`;
1824

19-
exports[`BundleDeployer01 should complain with missing zOSMF profile for undeploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
25+
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHRL2043I"`;
2026

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

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

@@ -359,7 +365,7 @@ UNDEPLOY BUNDLE(12345678)
359365
"
360366
`;
361367

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'."`;
368+
exports[`BundleDeployer01 should handle failure during submitjobs processing 1`] = `"Failure occurred submitting DFHDPLOY JCL: 'Injected Submit error'. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
363369

364370
exports[`BundleDeployer01 should support long bundledir 1`] = `
365371
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
@@ -503,7 +509,9 @@ UNDEPLOY BUNDLE(12345678)
503509
"
504510
`;
505511

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

525-
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `
533+
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `"DFHRL2037I"`;
534+
535+
exports[`BundleDeployer01 should support verbose=true output for undeploy 2`] = `
526536
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
527537
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
528538
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD
@@ -558,6 +568,6 @@ DEPLOY BUNDLE(12345678)
558568
"
559569
`;
560570

561-
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"DFHDPLOY did not generate any output. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
571+
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"DFHDPLOY did not generate any output. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
562572

563573
exports[`BundleDeployer01 should undeploy successfully 1`] = `"Bundle undeployment successful."`;

0 commit comments

Comments
 (0)