Skip to content

Commit 14f4ea4

Browse files
committed
push bundle command
1 parent 3c231e2 commit 14f4ea4

21 files changed

+1296
-354
lines changed

__tests__/api/BundleContent/BundleMocked.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,35 @@ describe("MockedFilesystemTests", () => {
534534
expect(err.message).toContain(".zosattributes'");
535535
expect(err.message).toContain("InjectedError");
536536
});
537+
it("should know if the bundle is valid", () => {
538+
jest.spyOn(fs, "accessSync").mockReturnValue(true);
539+
jest.spyOn(fs, "existsSync").mockReturnValue(false);
540+
jest.spyOn(fs, "writeFileSync").mockReturnValue(true);
541+
jest.spyOn(fs, "mkdirSync").mockReturnValue(true);
542+
543+
let err: Error;
544+
let bund;
545+
try {
546+
bund = new Bundle("__tests__/__resources__/ExampleBundle01", false, false);
547+
bund.validate();
548+
}
549+
catch (error) {
550+
err = error;
551+
}
552+
553+
expect(err).toBeDefined();
554+
expect(err.message).toContain("No bundle manifest file found");
555+
expect(err.message).toContain("cics.xml");
556+
557+
err = undefined;
558+
try {
559+
bund.save();
560+
bund.validate();
561+
}
562+
catch (error) {
563+
err = error;
564+
}
565+
566+
expect(err).toBeUndefined();
567+
});
537568
});

__tests__/api/BundleContent/BundleSimple.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,16 @@ describe("BundleDeployer01", () => {
6060
jest.resetAllMocks();
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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 SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
5+
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'."`;
66

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

@@ -14,9 +14,9 @@ exports[`BundleDeployer01 should complain if cpsmhlq not found2 1`] = `"EYU9ABSI
1414

1515
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `"DFHDPLOY command completed, but status cannot be determined."`;
1616

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

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

2121
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHDPLOY completed with warnings."`;
2222

@@ -359,7 +359,7 @@ UNDEPLOY BUNDLE(12345678)
359359
"
360360
`;
361361

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'."`;
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 for the DEPLOY action'."`;
363363

364364
exports[`BundleDeployer01 should support long bundledir 1`] = `
365365
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
@@ -540,6 +540,6 @@ UNDEPLOY BUNDLE(12345678)
540540
"
541541
`;
542542

543-
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"DFHDPLOY did not generate any output. Most recent status update: 'Submitting DFHDPLOY JCL'."`;
543+
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'."`;
544544

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

0 commit comments

Comments
 (0)