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

feat(list): Add maxLength and start options to List SDK functions #2409

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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
7 changes: 6 additions & 1 deletion packages/zosfiles/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

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


## Recent Changes

- Enhancement: The `Copy.dataset` function now creates a new data set if the entered target data set does not exist. [#2349](https://github.com/zowe/zowe-cli/issues/2349)
- Enhancement: Added the `maxLength` option to List SDK functions (`allMembers, dataSetsMatchingPattern, membersMatchingPattern`) to specify the maximum number of items to return. [#2409](https://github.com/zowe/zowe-cli/pull/2409)
- Enhancement: Added the `start` option to List SDK functions (`allMembers, dataSetsMatchingPattern, membersMatchingPattern`) to specify the first data set/member name to return in the response. [#2409](https://github.com/zowe/zowe-cli/pull/2409)

## `8.10.3`

- BugFix: The `Copy.dataset` method no longer copies all partitioned data set members if a member is passed to the function. [#2402](https://github.com/zowe/zowe-cli/pull/2402)

## `8.10.0`

- Enhancement: The `Copy.dataset` method now recognizes partitioned data sets and can copy members of a source PDS into an existing target PDS. [#2386](https://github.com/zowe/zowe-cli/pull/2386)

## `8.9.1`
Expand All @@ -18,6 +22,7 @@ All notable changes to the Zowe z/OS files SDK package will be documented in thi
- BugFix: Corrected the `Upload.BufferToUssFile()` SDK function to properly tag uploaded files. [#2378](https://github.com/zowe/zowe-cli/pull/2378)

## `8.9.0`

- Enhancement: Added a `List.membersMatchingPattern` method to download all members that match a specific pattern.[#2359](https://github.com/zowe/zowe-cli/pull/2359)

## `8.8.4`
Expand Down
133 changes: 121 additions & 12 deletions packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let REAL_SESSION: Session;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let defaultSystem: ITestPropertiesSchema;
let dsname: string;
let dsname2: string;
let path: string;
let filename: string;

Expand All @@ -34,6 +35,7 @@ describe("List command group", () => {

REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment);
dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.LIST`, false, 1);
dsname2 = dsname + '2';
Imperative.console.info("Using dsname:" + dsname);

const user = `${defaultSystem.zosmf.user.trim()}`.replace(/\./g, "");
Expand All @@ -48,12 +50,16 @@ describe("List command group", () => {

describe("All Members", () => {
describe("Success Scenarios", () => {
const testString = "test";
const memberOne = "test";
const memberTwo = "test2";
beforeEach(async () => {
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname,
{ volser: defaultSystem.datasets.vol });
await wait(waitTime); //wait 2 seconds
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testString), `${dsname}(${testString})`);
// first data set member
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(memberOne), `${dsname}(${memberOne})`);
// second data set member
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(memberOne), `${dsname}(${memberTwo})`);
await wait(waitTime); //wait 2 seconds
});

Expand All @@ -77,8 +83,47 @@ describe("List command group", () => {
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(2);
expect(response.apiResponse.items[0].member).toEqual(memberOne.toUpperCase());
expect(response.apiResponse.items[1].member).toEqual(memberTwo.toUpperCase());
});

it("should limit number of members when maxLength is provided", async () => {
let error;
let response: IZosFilesResponse;

try {
response = await List.allMembers(REAL_SESSION, dsname, {maxLength: 1});
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].member).toEqual(testString.toUpperCase());
expect(response.apiResponse.items[0].member).toEqual(memberOne.toUpperCase());
});

it("should return a list starting with the given member in the start option", async () => {
let error;
let response: IZosFilesResponse;

try {
response = await List.allMembers(REAL_SESSION, dsname, { start: memberTwo });
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].member).toEqual(memberTwo.toUpperCase());
});

it("should list all members of a data set with response timeout", async () => {
Expand All @@ -96,8 +141,9 @@ describe("List command group", () => {
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].member).toEqual(testString.toUpperCase());
expect(response.apiResponse.items.length).toBe(2);
expect(response.apiResponse.items[0].member).toEqual(memberOne.toUpperCase());
expect(response.apiResponse.items[1].member).toEqual(memberTwo.toUpperCase());
});

it("should list all members of a data set with attributes", async () => {
Expand All @@ -118,8 +164,9 @@ describe("List command group", () => {
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].member).toEqual(testString.toUpperCase());
expect(response.apiResponse.items.length).toBe(2);
expect(response.apiResponse.items[0].member).toEqual(memberOne.toUpperCase());
expect(response.apiResponse.items[1].member).toEqual(memberTwo.toUpperCase());
expect(response.apiResponse.items[0].user).toBeDefined();
});

Expand All @@ -129,7 +176,8 @@ describe("List command group", () => {
let error;

try {
await Delete.dataSet(REAL_SESSION, `${dsname}(${testString})`);
await Delete.dataSet(REAL_SESSION, `${dsname}(${memberOne})`);
await Delete.dataSet(REAL_SESSION, `${dsname}(${memberTwo})`);
await wait(waitTime); //wait 2 seconds
response = await List.allMembers(REAL_SESSION, dsname);
} catch (err) {
Expand Down Expand Up @@ -180,15 +228,18 @@ describe("List command group", () => {
beforeEach(async () => {
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname,
{ volser: defaultSystem.datasets.vol });
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname2,
{ volser: defaultSystem.datasets.vol });
await wait(waitTime); //wait 2 seconds
});

afterEach(async () => {
await Delete.dataSet(REAL_SESSION, dsname);
await Delete.dataSet(REAL_SESSION, dsname2);
await wait(waitTime); //wait 2 seconds
});

it("should list a data set", async () => {
it("should list data set matching dsname", async () => {
let error;
let response: IZosFilesResponse;

Expand All @@ -207,16 +258,35 @@ describe("List command group", () => {
expect(response.apiResponse.items[0].dsname).toEqual(dsname);
});

it("should limit amount of data sets with maxLength", async () => {
let error;
let response: IZosFilesResponse;

try {
response = await List.dataSet(REAL_SESSION, `${dsname}*`, { maxLength: 1 });
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].dsname).toEqual(dsname);
});

it("should list a data set with attributes and start options", async () => {
let error;
let response: IZosFilesResponse;
const option: IListOptions = {
attributes: true,
start: dsname
start: dsname2
};

try {
response = await List.dataSet(REAL_SESSION, dsname, option);
response = await List.dataSet(REAL_SESSION, `${dsname}*`, option);
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Expand All @@ -227,7 +297,7 @@ describe("List command group", () => {
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe(null);
expect(response.apiResponse.items.length).toBe(1);
expect(response.apiResponse.items[0].dsname).toEqual(dsname);
expect(response.apiResponse.items[0].dsname).toEqual(dsname2);
expect(response.apiResponse.items[0].dsorg).toBeDefined();
});

Expand Down Expand Up @@ -676,6 +746,7 @@ describe("List command group", () => {
await Delete.dataSet(REAL_SESSION, dsname);
await wait(waitTime); //wait 2 seconds
});

it("should find data sets that match a pattern", async () => {
let error;
let response: IZosFilesResponse;
Expand Down Expand Up @@ -728,6 +799,44 @@ describe("List command group", () => {
expect(response).toBeDefined();
expect(response.commandResponse).toContain("There are no members that match");
});

it("should limit number of members when maxLength is provided", async () => {
let error;
let response: IZosFilesResponse;

try {
response = await List.membersMatchingPattern(REAL_SESSION, dsname, [pattern], { maxLength: 1 });
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe("1 members(s) were found matching pattern.");
expect(response.apiResponse.length).toBe(1);
expect(response.apiResponse[0].member).toEqual(members[0]);
});

it("should return a list starting with the given member in the start option", async () => {
let error;
let response: IZosFilesResponse;

try {
response = await List.membersMatchingPattern(REAL_SESSION, dsname, [pattern], { start: "M1A" });
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}
expect(error).toBeFalsy();
expect(response).toBeTruthy();
expect(response.success).toBeTruthy();
expect(response.commandResponse).toBe("3 members(s) were found matching pattern.");
expect(response.apiResponse.length).toBe(3);
expect(response.apiResponse[0].member).toEqual(members[1]);
});
});

});
Expand Down
Loading
Loading