diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index 68d1652a6..88bd08530 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -36,6 +36,15 @@ exports[`issue command handler tests should issue command 1`] = ` }, undefined, Object { + "addressSpaceOptions": Object { + "account": "fake", + "characterSet": undefined, + "codePage": undefined, + "columns": undefined, + "logonProcedure": undefined, + "regionSize": undefined, + "rows": undefined, + }, "isStateful": undefined, "suppressStartupMessage": undefined, }, diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index c242a8182..42e939301 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -32,6 +32,7 @@ export default class Handler extends ZosTsoBaseHandler { isStateful: params.arguments.stateful, suppressStartupMessage: params.arguments.suppressStartupMessages, + addressSpaceOptions: this.mTsoStart } ); diff --git a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts index ed48b1dfe..c17ebef46 100644 --- a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts @@ -16,7 +16,8 @@ import * as fs from "fs"; import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; - +import { IIssueTsoCmdParms } from "../../src"; +import { IIssueTsoCmdOpts } from "../../src/doc/input/IIssueTsoCmdOpts"; let testEnvironment: ITestEnvironment; let systemProperties: ITestPropertiesSchema; let REAL_SESSION: Session; @@ -24,7 +25,8 @@ let ACCOUNT_NUMBER: string; let START_PARAMS: IStartTsoParms; let ISSUE_PARAMS: IIssueTsoParms; - +let COMMAND_PARAMS: IIssueTsoCmdParms; +let AS_OPTIONS: IIssueTsoCmdOpts; describe("IssueTso.issueTsoCommand", () => { beforeAll(async () => { @@ -50,9 +52,18 @@ describe("IssueTso.issueTsoCommand", () => { accountNumber: ACCOUNT_NUMBER, startParams: START_PARAMS }; - + COMMAND_PARAMS = { + command: "TIME" + } + AS_OPTIONS = { + addressSpaceOptions: START_PARAMS + } + }); + afterAll(async () => { + AS_OPTIONS = { + addressSpaceOptions: START_PARAMS + } }); - it("should display time", async () => { let error: ImperativeError; let response: IIssueResponse; @@ -81,4 +92,29 @@ describe("IssueTso.issueTsoCommand", () => { const regex = fs.readFileSync(__dirname + "/__regex__/d_time.regex").toString(); expect(new RegExp(regex, "g").test(response.commandResponse.toString())).toBe(true); }); + it("should display time - issueTsoCmd() - new API - pass", async () => { + let error: ImperativeError; + let response: IIssueResponse; + try { + response = await IssueTso.issueTsoCmd(REAL_SESSION, "TIME", AS_OPTIONS); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + const regex = fs.readFileSync(__dirname + "/__regex__/d_time.regex").toString(); + expect(new RegExp(regex, "g").test(response.commandResponse.toString())).toBe(true); + }); + it("should fail - issueTsoCmd() - 404 error", async () => { + REAL_SESSION.ISession.basePath = "/bad/path/to/nothing" + let error: ImperativeError; + let response: IIssueResponse; + try { + response = await IssueTso.issueTsoCmd(REAL_SESSION, "TIME", AS_OPTIONS); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(response).toBeUndefined(); + }); }); diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index fe40d75fb..3404c6502 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -140,6 +140,9 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { expect(error).toBeDefined(); }); it("should fail when StartTSO fails", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) + ); let error: ImperativeError; let response: ISendResponse; @@ -168,6 +171,9 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { describe("TsoIssue issueTsoCommand - Deprecated API", () => { it("should succeed", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) + ); (StartTso.start as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 90541a37b..c9f12525e 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -36,9 +36,8 @@ export class IssueTso { let command: string | IIssueTsoCmdParms; let version: string; opts = opts || {}; - let useNewApi = - opts.addressSpaceOptions == null && + opts.addressSpaceOptions == null || await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 @@ -78,8 +77,6 @@ export class IssueTso { } // Deprecated API Behavior [former issueTsoCommand() behavior] if (opts.addressSpaceOptions != null || !useNewApi) { - const profInfo = ImperativeConfig.instance.config.api.profiles.defaultGet("tso"); - opts.addressSpaceOptions = { ...opts.addressSpaceOptions, ...profInfo}; command = typeof commandInfo === "string" ? commandInfo