Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement fix for #1825 #1826

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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