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

Implementation of new "like" parameter for data set creation #766

Merged
merged 28 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e749b6f
Implementation of new "like" parameter for data set creation
katelynienaber Jul 20, 2020
0ea50c4
Adding unit tests & changelog
katelynienaber Jul 20, 2020
fbd7afc
Fixing unit tests
katelynienaber Jul 20, 2020
f677a76
Fixing lint
katelynienaber Jul 20, 2020
97e64f6
Fixes according to zFernand0's comments
katelynienaber Jul 20, 2020
e22781f
Fixing unit test
katelynienaber Jul 20, 2020
5121cc4
Fix changelog
katelynienaber Jul 20, 2020
a630ca5
Fixes according to tjohnsonBCM's comments (part 1)
katelynienaber Jul 20, 2020
a472586
Fixing accidental setting of secondary parameter
katelynienaber Jul 20, 2020
f45a97a
Wrap system test in TestEnvironment
t1m0thyj Jul 20, 2020
6391e05
Adding new interface for allocate like
katelynienaber Jul 22, 2020
8e4cc92
Merge remote-tracking branch 'refs/remotes/origin/add-like-param' int…
katelynienaber Jul 22, 2020
323473d
Adding interface ICreateDataSetLikeOptions and function dataSetLike i…
katelynienaber Jul 22, 2020
61bc393
Merge branch 'master' into add-like-param
katelynienaber Jul 22, 2020
d084aab
Fix unit test
katelynienaber Jul 22, 2020
58567bf
Merge branch 'add-like-param' of github.com:zowe/zowe-cli into add-li…
katelynienaber Jul 22, 2020
3ef1f78
fixing unit tests
katelynienaber Jul 22, 2020
0bede6b
Fixes accourding to tjohnsonBCM's comments (part 2)
katelynienaber Jul 23, 2020
e104a06
Merge branch 'master' into add-like-param
katelynienaber Jul 23, 2020
a67bc99
Fixes according to tjohnsonBCM's comments
katelynienaber Jul 27, 2020
38890a5
Merge branch 'add-like-param' of github.com:zowe/zowe-cli into add-li…
katelynienaber Jul 27, 2020
169face
Unit test fix
katelynienaber Jul 27, 2020
42314ff
Remove returned ds attributes from allocateLike
katelynienaber Jul 28, 2020
a145ea9
Fixes (last ones?? Fingers crossed) according to tjohnsonBCM's comments
katelynienaber Jul 29, 2020
52428dd
Merge branch 'master' into add-like-param
katelynienaber Jul 29, 2020
c9ef796
Fixing imperative version after merge
katelynienaber Jul 29, 2020
b07a32e
Fixes according to zFernand0's comments
katelynienaber Jul 30, 2020
c4fa836
zFernand0 fix
katelynienaber Jul 30, 2020
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 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

- Add "like" parameter to `ICreateDataSetOptions` type (implementation of new zOSMF "like" REST parameter in API)

## `6.18.0`

- Add the --fail-fast option to the `zowe zos-files download all-members` command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,73 @@ describe("Create data set", () => {
}, LONGER_TIMEOUT);
});

describe("Allocate Like", () => {
let dsnameLike: string;
const options: ICreateDataSetOptions = {
dsorg: "PO",
alcunit: "CYL",
primary: 20,
recfm: "FB",
blksize: 6160,
lrecl: 80,
showAttributes: true
} as any;

beforeAll(async () => {
testEnvironment = await TestEnvironment.setUp({
testName: "zos_create_dataset_like"
});
defaultSystem = testEnvironment.systemTestProperties;

REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment);
dsnameLike = `${dsname}.LIKE`;
});

afterAll(async () => {
await TestEnvironment.cleanUp(testEnvironment);
});

beforeEach(async () => {
try {
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_CLASSIC, dsname, options);
} catch (error) {
Imperative.console.info("Error: " + inspect(error));
}
});

afterEach(async () => {
try {
await Delete.dataSet(REAL_SESSION, dsname);
await Delete.dataSet(REAL_SESSION, dsnameLike);
} catch (error) {
Imperative.console.info("Error: " + inspect(error));
}
});

it("should be able to allocate like from a sequential data set", async () => {
const options2: ICreateDataSetOptions = {
like: dsname,
showAttributes: true
} as any;
let error;
let response;

try {
response = await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_LIKE, dsnameLike, options2);
Imperative.console.info("Response: " + inspect(response));
} catch (err) {
error = err;
Imperative.console.info("Error: " + inspect(error));
}

expect(error).toBeFalsy();
expect(response).toBeTruthy();
katelynienaber marked this conversation as resolved.
Show resolved Hide resolved

expect(response.success).toBe(true);
expect(response.commandResponse).toContain(ZosFilesMessages.dataSetCreatedSuccessfully.message);
});
})

describe("Create VSAM", () => {

beforeAll(async () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ImperativeError, TextUtils } from "@zowe/imperative";
import { Create, CreateDataSetTypeEnum, ZosFilesConstants, CreateDefaults, Invoke, ICreateVsamOptions } from "../../../../";
import { ZosmfRestClient } from "../../../../../rest/";
import { ZosFilesMessages } from "../../../../src/api/constants/ZosFiles.messages";
import { Get, List } from "../../../../src/api";
katelynienaber marked this conversation as resolved.
Show resolved Hide resolved

describe("Create data set", () => {
const dummySession: any = {};
Expand Down Expand Up @@ -139,6 +140,14 @@ describe("Create data set", () => {
);
});

it("should be able to allocate like from a sequential data set", async () => {
katelynienaber marked this conversation as resolved.
Show resolved Hide resolved
const custOptions2 = { like: dataSetName, showAttributes: true };

const response = await Create.dataSet(dummySession, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, "testing2", custOptions2);

expect(response.commandResponse).toContain("created successfully");
});

it("should be able to create a sequential data set using the primary allocation and secondary allocation options", async () => {
const custOptions = {
dsorg: "PS",
Expand Down
12 changes: 11 additions & 1 deletion packages/zosfiles/src/api/methods/create/Create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export class Create {
// Required
ImperativeExpect.toNotBeNullOrUndefined(dataSetName, ZosFilesMessages.missingDatasetName.message);

// Remove type if "like" attribute is set...attributes will be determined from other data set
if (!isNullOrUndefined(tempOptions.like)) { cmdType = CreateDataSetTypeEnum.DATA_SET_LIKE }

switch (cmdType) {
case CreateDataSetTypeEnum.DATA_SET_PARTITIONED:
tempOptions = {...CreateDefaults.DATA_SET.PARTITIONED, ...tempOptions};
Expand All @@ -70,6 +73,9 @@ export class Create {
case CreateDataSetTypeEnum.DATA_SET_CLASSIC:
tempOptions = {...CreateDefaults.DATA_SET.CLASSIC, ...tempOptions};
break;
case CreateDataSetTypeEnum.DATA_SET_LIKE:
// "like" attribute is set, so attributes should not be added
break;
default:
validCmdType = false;
break;
Expand All @@ -96,7 +102,7 @@ export class Create {
}
}
} else {
if (isNullOrUndefined(tempOptions.secondary)) {
if (isNullOrUndefined(tempOptions.secondary) && cmdType !== CreateDataSetTypeEnum.DATA_SET_LIKE) {
if (cmdType !== CreateDataSetTypeEnum.DATA_SET_BINARY) {
tempOptions.secondary = 1;
} else {
Expand Down Expand Up @@ -271,6 +277,10 @@ export class Create {
case "volser":
// no validation

break;
case "like":
// no validation

break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export const enum CreateDataSetTypeEnum {
DATA_SET_C,
DATA_SET_CLASSIC,
DATA_SET_PARTITIONED,
DATA_SET_SEQUENTIAL
DATA_SET_SEQUENTIAL,
DATA_SET_LIKE
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ export interface ICreateDataSetOptions {
* @type {string}
*/
size?: string;
/**
* The name of another data set from which to copy attributes
* @type {string}
*/
like?: string;
katelynienaber marked this conversation as resolved.
Show resolved Hide resolved
}