Skip to content

Commit 1b1b8ca

Browse files
committed
couple of unit tests
1 parent 65366a8 commit 1b1b8ca

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { BundleDeployer } from "../../../src/api/BundleDeploy/BundleDeployer";
1313
import { IHandlerParameters } from "@brightside/imperative";
1414
import * as DeployBundleDefinition from "../../../src/cli/deploy/bundle/DeployBundle.definition";
1515
import * as fse from "fs-extra";
16+
import { ZosmfSession, SubmitJobs, List } from "@brightside/core";
1617

1718

1819
const DEFAULT_PARAMTERS: IHandlerParameters = {
@@ -55,6 +56,44 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
5556

5657
describe("BundleDeployer01", () => {
5758

59+
it("should complain with missing zOSMF profile for deploy", async () => {
60+
61+
let parms: IHandlerParameters;
62+
parms = DEFAULT_PARAMTERS;
63+
setCommonParmsForDeployTests(parms);
64+
parms.arguments.csdgroup = "12345678";
65+
66+
// Create a Bundle
67+
const bd = new BundleDeployer(parms);
68+
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();
77+
});
78+
it("should complain with missing zOSMF profile for undeploy", async () => {
79+
80+
let parms: IHandlerParameters;
81+
parms = DEFAULT_PARAMTERS;
82+
setCommonParmsForDeployTests(parms);
83+
parms.arguments.csdgroup = "12345678";
84+
85+
// Create a Bundle
86+
const bd = new BundleDeployer(parms);
87+
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();
96+
});
5897
it("should generate deploy JCL for csdgroup", () => {
5998

6099
let parms: IHandlerParameters;

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

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

3+
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
4+
5+
exports[`BundleDeployer01 should complain with missing zOSMF profile for undeploy 1`] = `"Expect Error: Required parameter 'hostname' must be defined"`;
6+
37
exports[`BundleDeployer01 should generate deploy JCL for csdgroup 1`] = `
48
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
59
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M

src/api/BundleDeploy/BundleDeployer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class BundleDeployer {
4747
ParmValidator.validateDeploy(this.params);
4848

4949
// Create a zosMF session
50-
const session = this.createZosMFSession();
50+
const session = await this.createZosMFSession();
5151

5252
// Check that the CICS dataset value looks valid and can be viewed
5353
await this.checkHLQDatasets(session);
@@ -71,7 +71,7 @@ export class BundleDeployer {
7171
ParmValidator.validateUndeploy(this.params);
7272

7373
// Create a zosMF session
74-
const session = this.createZosMFSession();
74+
const session = await this.createZosMFSession();
7575

7676
// Check that the CICS dataset value looks valid and can be viewed
7777
await this.checkHLQDatasets(session);
@@ -164,7 +164,7 @@ export class BundleDeployer {
164164
}
165165

166166

167-
private createZosMFSession(): Session {
167+
private async createZosMFSession(): Promise<Session> {
168168
// Create a zosMF session
169169
const zosmfProfile = this.params.profiles.get("zosmf");
170170

0 commit comments

Comments
 (0)