Skip to content

Commit

Permalink
Merge pull request #1826 from zowe/various-fixes-v2
Browse files Browse the repository at this point in the history
Implement fix for #1825
  • Loading branch information
zFernand0 authored Oct 17, 2023
2 parents f222396 + 4d55679 commit 4e76260
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- BugFix: Fix bug where encoding is not passed to the Download USS Directory API [#1825](https://github.com/zowe/zowe-cli/issues/1825)

## `7.18.7`

- BugFix: Bump Imperative to `5.18.2` to fix issues with normalizing newlines on file uploads [#1815](https://github.com/zowe/zowe-cli/issues/1815)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,76 @@ describe("Download uss dir handler", () => {
expect(logMessage).toMatchSnapshot();
});

it("should download a uss dir in an encoding", async () => {
// Require the handler and create a new instance
const handlerReq = require("../../../../../src/zosfiles/download/ussdir/UssDir.handler");
const handler = new handlerReq.default();
const ussDirName = "/z/testingDirectory";

const localDownloadObj: IDownloadOptions = {...defaultDownloadObj, encoding: "IBM-037"};
const localListObj: IUSSListOptions = {...defaultListObj};

// Vars populated by the mocked function
let error;
let apiMessage = "";
let jsonObj;
let logMessage = "";
let fakeSession = null;

Download.ussDir = jest.fn(async (session) => {
fakeSession = session;
return {
success: true,
commandResponse: "downloaded"
};
});

try {
// Invoke the handler with a full set of mocked arguments and response functions
await handler.process({
arguments: {
$0: "fake",
_: ["fake"],
ussDirName,
encoding: "IBM-037",
...UNIT_TEST_ZOSMF_PROF_OPTS
},
response: {
data: {
setMessage: jest.fn((setMsgArgs) => {
apiMessage = setMsgArgs;
}),
setObj: jest.fn((setObjArgs) => {
jsonObj = setObjArgs;
})
},
console: {
log: jest.fn((logArgs) => {
logMessage += "\n" + logArgs;
})
},
progress: {
startBar: jest.fn((parms) => {
// do nothing
}),
endBar: jest.fn(() => {
// do nothing
})
}
}
} as any);
} catch (e) {
error = e;
}

expect(error).toBeUndefined();
expect(Download.ussDir).toHaveBeenCalledTimes(1);
expect(Download.ussDir).toHaveBeenCalledWith(fakeSession, ussDirName, localDownloadObj, localListObj);
expect(jsonObj).toMatchSnapshot();
expect(apiMessage).toMatchSnapshot();
expect(logMessage).toMatchSnapshot();
});

it("should download a uss dir and look for a particular file", async () => {
// Require the handler and create a new instance
const handlerReq = require("../../../../../src/zosfiles/download/ussdir/UssDir.handler");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,17 @@ exports[`Download uss dir handler process method should download a uss dir if re
"
downloaded"
`;

exports[`Download uss dir handler process method should download a uss dir in an encoding 1`] = `
Object {
"commandResponse": "downloaded",
"success": true,
}
`;

exports[`Download uss dir handler process method should download a uss dir in an encoding 2`] = `""`;

exports[`Download uss dir handler process method should download a uss dir in an encoding 3`] = `
"
downloaded"
`;
3 changes: 2 additions & 1 deletion packages/cli/src/zosfiles/download/ussdir/UssDir.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default class UssDirHandler extends ZosFilesBaseHandler {
failFast: commandParameters.arguments.failFast,
attributes: zosAttributes,
includeHidden: commandParameters.arguments.includeHidden,
overwrite: commandParameters.arguments.overwrite
overwrite: commandParameters.arguments.overwrite,
encoding: commandParameters.arguments.encoding
};
const listOptions: IUSSListOptions = {
name: commandParameters.arguments.name ? commandParameters.arguments.name : "*",
Expand Down

0 comments on commit 4e76260

Please sign in to comment.