Skip to content

Commit

Permalink
Merge branch 'master' into addressSpaceApps
Browse files Browse the repository at this point in the history
Signed-off-by: Jace Roell <111985297+jace-roell@users.noreply.github.com>
  • Loading branch information
jace-roell authored Oct 29, 2024
2 parents 6ddbd17 + 4b7a194 commit b62ea56
Show file tree
Hide file tree
Showing 36 changed files with 747 additions and 64 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "8.3.1",
"version": "8.5.0",
"command": {
"publish": {
"ignoreChanges": [
Expand Down
18 changes: 9 additions & 9 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.

## `8.4.0`

- Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319)

## `8.3.0`

- Enhancement: Issue the `zowe files search data-sets` command with the new `encoding` option to use a different code page when searching data set contents. [#2161](https://github.com/zowe/zowe-cli/issues/2161)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

import { Upload } from "@zowe/zos-files-for-zowe-sdk";
import { Upload, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk";
import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants";

describe("Upload file-to-uss handler", () => {
Expand All @@ -29,7 +29,7 @@ describe("Upload file-to-uss handler", () => {
let fakeSession = null;

// Mock the submit JCL function
Upload.fileToUssFile = jest.fn(async (session, file, name, options = {}) => {
Upload.uploadFile = jest.fn(async (session, file, name, options = {}) => {
fakeSession = session;
return {
success: true,
Expand Down Expand Up @@ -79,20 +79,111 @@ describe("Upload file-to-uss handler", () => {
}

expect(error).toBeUndefined();
expect(Upload.fileToUssFile).toHaveBeenCalledTimes(1);
expect(Upload.fileToUssFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, {
expect(Upload.uploadFile).toHaveBeenCalledTimes(1);
expect(Upload.uploadFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, {
binary: undefined,
encoding: undefined,
task: {
percentComplete: 0,
stageName: 0,
statusMessage: "Uploading USS file"
}
},
includeHidden: undefined,
maxConcurrentRequests: undefined,
responseTimeout: undefined
});
expect(jsonObj).toMatchSnapshot();
expect(apiMessage).toMatchSnapshot();
expect(logMessage).toMatchSnapshot();
});
it("should upload a file to a USS if requested - zosattributes file", async () => {
// Require the handler and create a new instance
const handlerReq = require("../../../../../src/zosfiles/upload/ftu/FileToUSS.handler");
const handler = new handlerReq.default();
const inputfile = "test-file";
const USSFileName = "testing";
let zosAttributes: any;

let error;
let apiMessage = "";
let jsonObj;
let logMessage = "";
let fakeSession = null;

jest.spyOn(ZosFilesAttributes, "loadFromFile").mockImplementation(() => {
zosAttributes = Object.create(ZosFilesAttributes.prototype);
zosAttributes.attributes = new Map([
['*.json', { ignore: true }],
['*.bin', { ignore: false, localEncoding: 'binary', remoteEncoding: 'binary' }],
['*.jcl', { ignore: false, localEncoding: 'IBM-1047', remoteEncoding: 'IBM-1047' }],
['*.md', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'UTF-8' }],
['*.txt', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'IBM-1047' }]
]);
zosAttributes.basePath = undefined;
return zosAttributes;
});
Upload.uploadFile = jest.fn(async (session, file, name, options = {}) => {
fakeSession = session;
return {
success: true,
commandResponse: "uploaded",
apiResponse: [
{ success: true, from: inputfile, to: USSFileName }
]
};
});
try {
await handler.process({
arguments: {
$0: "fake",
_: ["fake"],
inputfile,
USSFileName,
...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(() => {
// do nothing
}),
endBar: jest.fn(() => {
// do nothing
})
}
}
} as any);
} catch (e) {
error = e;
}
expect(error).toBeUndefined();
expect(Upload.uploadFile).toHaveBeenCalledTimes(1);
expect(Upload.uploadFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, {
attributes: zosAttributes,
binary: undefined,
includeHidden: undefined,
maxConcurrentRequests: undefined,
responseTimeout: undefined,
task: {
percentComplete: 0,
stageName: 0,
statusMessage: "Uploading USS file"
}
});
expect(jsonObj).toMatchSnapshot();
expect(apiMessage).toMatchSnapshot();
expect(logMessage).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ Array [
"name": "encoding",
"type": "string",
},
Object {
"aliases": Array [
"attrs",
],
"conflictsWith": Array [
"ascii-files, binary-files",
],
"description": "Path of an attributes file to control how files are uploaded.",
"name": "attributes",
"type": "string",
},
]
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 1`] = `
Object {
"apiResponse": Array [
Object {
"from": "test-file",
"success": true,
"to": "testing",
},
],
"commandResponse": "uploaded",
"success": true,
}
`;

exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 2`] = `""`;

exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 3`] = `
"
- 
success: true
from:  test-file
to:  testing
uploaded"
`;

exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 1`] = `
Object {
"apiResponse": Array [
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export class GetJobsData {
public static readonly SAMPLE_COMPLETE_JOB: IJob = {
"jobid": "TSUxxx",
"jobname": "IBMUSER$",
"exec-started": '2024-01-02T15:57:58.350Z',
"exec-ended": '2024-01-02T15:58:00.600Z',
"exec-member": 'SYS1',
"exec-system": 'SYS1',
"exec-submitted": '2024-01-02T15:58:00.600Z',
"subsystem": "JES2",
"owner": "IBMUSER",
"status": "OUTPUT",
Expand All @@ -49,6 +54,11 @@ export class GetJobsData {
public static readonly SAMPLE_COMPLETE_JOB_AGAIN: IJob = {
"jobid": "JOBxxx",
"jobname": "CAUSER$",
"exec-started": '2024-01-02T15:57:58.350Z',
"exec-ended": '2024-01-02T15:58:00.600Z',
"exec-member": 'SYS1',
"exec-system": 'SYS1',
"exec-submitted": '2024-01-02T15:58:00.600Z',
"subsystem": "JES2",
"owner": "CAUSER",
"status": "OUTPUT",
Expand Down Expand Up @@ -79,6 +89,11 @@ export class GetJobsData {
public static readonly SAMPLE_ACTIVE_JOB: IJob = {
"retcode": null,
"jobname": "KELDA16$",
"exec-started": '2024-01-02T15:57:58.350Z',
"exec-ended": '2024-01-02T15:58:00.600Z',
"exec-member": 'SYS1',
"exec-system": 'SYS1',
"exec-submitted": '2024-01-02T15:58:00.600Z',
"status": "INPUT",
"job-correlator": "J0003781USILDAMDD3CE8146.......:",
"class": "A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ exports[`cancel job handler tests should be able to cancel a job by job id 2`] =
exports[`cancel job handler tests should be able to cancel a job by job id 3`] = `
Object {
"class": "A",
"exec-ended": "2024-01-02T15:58:00.600Z",
"exec-member": "SYS1",
"exec-started": "2024-01-02T15:57:58.350Z",
"exec-submitted": "2024-01-02T15:58:00.600Z",
"exec-system": "SYS1",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
Expand All @@ -29,6 +34,11 @@ exports[`cancel job handler tests should be able to cancel a job by job id versi
exports[`cancel job handler tests should be able to cancel a job by job id version 2.0 3`] = `
Object {
"class": "A",
"exec-ended": "2024-01-02T15:58:00.600Z",
"exec-member": "SYS1",
"exec-started": "2024-01-02T15:57:58.350Z",
"exec-submitted": "2024-01-02T15:58:00.600Z",
"exec-system": "SYS1",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ exports[`delete job handler tests should be able to delete a job by job id 2`] =
exports[`delete job handler tests should be able to delete a job by job id 3`] = `
Object {
"class": "A",
"exec-ended": "2024-01-02T15:58:00.600Z",
"exec-member": "SYS1",
"exec-started": "2024-01-02T15:57:58.350Z",
"exec-submitted": "2024-01-02T15:58:00.600Z",
"exec-system": "SYS1",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
Expand All @@ -29,6 +34,11 @@ exports[`delete job handler tests should be able to delete a job by job id versi
exports[`delete job handler tests should be able to delete a job by job id version 2.0 3`] = `
Object {
"class": "A",
"exec-ended": "2024-01-02T15:58:00.600Z",
"exec-member": "SYS1",
"exec-started": "2024-01-02T15:57:58.350Z",
"exec-submitted": "2024-01-02T15:58:00.600Z",
"exec-system": "SYS1",
"files-url": "www.nowhere.com/restjobs/jobs/files",
"job-correlator": "123545asdfadf",
"jobid": "TSUxxx",
Expand Down
Loading

0 comments on commit b62ea56

Please sign in to comment.