Skip to content

Commit

Permalink
Merge pull request #1833 from zowe/fix-1722
Browse files Browse the repository at this point in the history
Implement fix for #1722
  • Loading branch information
zFernand0 authored Oct 27, 2023
2 parents d803b35 + 0e0e8d8 commit 7009f27
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
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 behavior where a specified directory was being lowercased on non-PDS datasets when downloading all datasets [#1722](https://github.com/zowe/zowe-cli/issues/1722)

## `7.18.8`

- BugFix: Fix bug where encoding is not passed to the Download USS Directory API [#1825](https://github.com/zowe/zowe-cli/issues/1825)
Expand Down
4 changes: 4 additions & 0 deletions packages/zosfiles/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe z/OS files SDK package will be documented in this file.

## Recent Changes

- BugFix: Fix behavior where a specified directory was being lowercased on non-PDS datasets when downloading all datasets [#1722](https://github.com/zowe/zowe-cli/issues/1722)

## `7.18.8`
- Enhancement: Patch that adds invalidFileName to ZosFilesMessages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,39 @@ describe("z/OS Files - Download", () => {
});
});

it("should download all members specifying mixed case directory, volume, and extension", async () => {
let response;
let caughtError;

const volume = "testVs";
const directory = "My/Test/Path/";
const extension = ".xyz";

try {
response = await Download.allMembers(dummySession, dsname, {volume, directory, extension});
} catch (e) {
caughtError = e;
}

expect(caughtError).toBeUndefined();
expect(response).toEqual({
success: true,
commandResponse: util.format(ZosFilesMessages.datasetDownloadedWithDestination.message, directory),
apiResponse: listApiResponse
});

expect(listAllMembersSpy).toHaveBeenCalledTimes(1);
expect(listAllMembersSpy).toHaveBeenCalledWith(dummySession, dsname, {volume});

expect(downloadDatasetSpy).toHaveBeenCalledTimes(2);
listApiResponse.items.forEach((mem) => {
expect(downloadDatasetSpy).toHaveBeenCalledWith(dummySession, `${dsname}(${mem.member})`, {
volume,
file: `${directory}/${mem.member.toLowerCase()}${extension}`
});
});
});

it("should download all members with specified \"\" extension", async () => {
let response;
let caughtError;
Expand Down Expand Up @@ -1279,6 +1312,42 @@ describe("z/OS Files - Download", () => {
expect(Download.dataSet).toHaveBeenCalledWith(dummySession, dataSetPS.dsname, {file: "my/test/path/test.ps.data.set.xyz"});
});

it("should download all datasets specifying a mixed case directory", async () => {
let response;
let caughtError;

const directory = "My/Test/Path";
const extensionMap = {set: "file"};

Download.dataSet = jest.fn(async (): Promise<any> => {
return {
commandResponse: "Data set downloaded",
apiResponse: {
items: [dataSetPS]
},
};
});

try {
response = await Download.allDataSets(dummySession, [dataSetPS] as any, {directory, extensionMap});
} catch (e) {
caughtError = e;
}

expect(caughtError).toBeUndefined();
expect(response).toEqual({
success: true,
commandResponse: (Download as any).buildDownloadDsmResponse({
downloaded: ["TEST.PS.DATA.SET"],
failedArchived: [],
failedUnsupported: [],
failedWithErrors: {}
}, {directory}),
apiResponse: [{ ...dataSetPS, status: "Data set downloaded" }]
});
expect(Download.dataSet).toHaveBeenCalledWith(dummySession, dataSetPS.dsname, {extensionMap, file: "My/Test/Path/test.ps.data.set.file"});
});

it("should download all datasets specifying the directory and extension map 1", async () => {
let response;
let caughtError;
Expand Down
4 changes: 2 additions & 2 deletions packages/zosfiles/src/methods/download/Download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ export class Download {
} else if (dataSetObj.dsorg === "PO" || dataSetObj.dsorg === "PO-E") {
mutableOptions.directory = `${mutableOptions.directory}/${ZosFilesUtils.getDirsFromDataSet(dataSetObj.dsname)}`;
} else {
mutableOptions.file = `${mutableOptions.directory}/${dataSetObj.dsname}.` +
`${mutableOptions.extension ?? ZosFilesUtils.DEFAULT_FILE_EXTENSION}`;
mutableOptions.file = `${dataSetObj.dsname}.${mutableOptions.extension ?? ZosFilesUtils.DEFAULT_FILE_EXTENSION}`;
if (!options.preserveOriginalLetterCase) {
mutableOptions.file = mutableOptions.file.toLowerCase();
}
mutableOptions.file = `${mutableOptions.directory}/${mutableOptions.file}`;
mutableOptions.directory = undefined;
mutableOptions.extension = undefined;
}
Expand Down

0 comments on commit 7009f27

Please sign in to comment.