From bae96fdbfdf6ac7a283c06243bd7c7eb009072ee Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Thu, 22 Feb 2024 16:30:37 -0500 Subject: [PATCH 01/14] removing custom handling and using standard error handling Signed-off-by: Amber Torrise --- .../upload/ftds/FileToDataSet.handler.ts | 57 ++++++------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts index 0a590f76eb..30c3262b50 100644 --- a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts @@ -9,10 +9,10 @@ * */ -import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage, TextUtils } from "@zowe/imperative"; -import { IZosFilesResponse, Upload, IUploadResult } from "@zowe/zos-files-for-zowe-sdk"; +import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage } from "@zowe/imperative"; +import { IZosFilesResponse, Upload } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; - +import { promises as fs } from 'fs'; /** * Handler to upload content from a file to a data set * @export @@ -21,50 +21,27 @@ export default class FileToDataSetHandler extends ZosFilesBaseHandler { public async processWithSession(commandParameters: IHandlerParameters, session: AbstractSession): Promise { + const inputFile = commandParameters.arguments.inputfile; + const dataSetName = commandParameters.arguments.dataSetName; + + // Check for file's existence + try { + await fs.access(inputFile, fs.constants.F_OK | fs.constants.R_OK); + } catch (error) { + throw new Error(`Failed to access the input file: ${inputFile}. Error: ${error.message}`); + } + + // Then upload existing file const task: ITaskWithStatus = { percentComplete: 0, statusMessage: "Uploading to data set", stageName: TaskStage.IN_PROGRESS }; commandParameters.response.progress.startBar({task}); - const response = await Upload.fileToDataset(session, commandParameters.arguments.inputfile, - commandParameters.arguments.dataSetName, - { - volume: commandParameters.arguments.volumeSerial, - binary: commandParameters.arguments.binary, - record: commandParameters.arguments.record, - encoding: commandParameters.arguments.encoding, - task, - responseTimeout: commandParameters.arguments.responseTimeout - }); - if (response.apiResponse) { - let skipCount: number = 0; - let successCount: number = 0; - let errorCount: number = 0; - response.apiResponse.forEach((element: IUploadResult) => { - if (element.success === true) { - const formatMessage = TextUtils.prettyJson(element); - commandParameters.response.console.log(formatMessage); - successCount++; - } else if (element.success === false) { - - const formatMessage = TextUtils.prettyJson(element); - commandParameters.response.console.error(TextUtils.chalk.red(formatMessage)); - errorCount++; - } else { - skipCount++; - } - }); - - commandParameters.response.console.log(TextUtils.prettyJson({ - file_to_upload: response.apiResponse.length, - success: successCount, - error: errorCount, - skipped: skipCount - })); - } + const response = await Upload.fileToDataset(session, inputFile, dataSetName, { + }); return response; } -} +} \ No newline at end of file From cb69048104d5670c8f30d61ed659d4c7f579017b Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Thu, 22 Feb 2024 17:02:02 -0500 Subject: [PATCH 02/14] standardizing files upload dtp Signed-off-by: Amber Torrise --- .../zosfiles/upload/dtp/DirToPds.handler.ts | 50 ++++++++----------- .../upload/ftds/FileToDataSet.handler.ts | 2 +- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index 48297f63d1..58368d5c10 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -9,27 +9,43 @@ * */ -import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage, TextUtils } from "@zowe/imperative"; -import { IZosFilesResponse, Upload, IUploadResult } from "@zowe/zos-files-for-zowe-sdk"; +import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage } from "@zowe/imperative"; +import { IZosFilesResponse, Upload } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; +import { promises as fs } from 'fs'; /** * Handler to upload content of a directory to a PDS * @export + * */ export default class DirToPdsHandler extends ZosFilesBaseHandler { public async processWithSession(commandParameters: IHandlerParameters, session: AbstractSession): Promise { + const inputDir = commandParameters.arguments.inputdir; + + // Check directory existence and accessibility + try { + const dirStats = await fs.stat(inputDir); + if (!dirStats.isDirectory()) { + throw new Error(`${inputDir} is not a directory.`); + } + } catch (error) { + // If the directory does not exist, is not accessible, or is not a directory, throw an error + throw new Error(`${error.message}`); + } + const status: ITaskWithStatus = { statusMessage: "Uploading directory to PDS", percentComplete: 0, stageName: TaskStage.IN_PROGRESS }; commandParameters.response.progress.startBar({task: status}); + const response = await Upload.dirToPds( session, - commandParameters.arguments.inputdir, + inputDir, commandParameters.arguments.dataSetName, { volume: commandParameters.arguments.volumeSerial, @@ -41,33 +57,7 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { } ); - if (response.apiResponse) { - let skipCount: number = 0; - let successCount: number = 0; - let errorCount: number = 0; - response.apiResponse.forEach((element: IUploadResult) => { - if (element.success === true) { - const formatMessage = TextUtils.prettyJson(element); - commandParameters.response.console.log(formatMessage); - successCount++; - } else if (element.success === false) { - - const formatMessage = TextUtils.prettyJson(element); - commandParameters.response.console.error(TextUtils.chalk.red(formatMessage)); - errorCount++; - } else { - skipCount++; - } - }); - - commandParameters.response.console.log(TextUtils.prettyJson({ - file_to_upload: response.apiResponse.length, - success: successCount, - error: errorCount, - skipped: skipCount - })); - } - return response; } } + diff --git a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts index 30c3262b50..15f94e7a42 100644 --- a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts @@ -28,7 +28,7 @@ export default class FileToDataSetHandler extends ZosFilesBaseHandler { try { await fs.access(inputFile, fs.constants.F_OK | fs.constants.R_OK); } catch (error) { - throw new Error(`Failed to access the input file: ${inputFile}. Error: ${error.message}`); + throw new Error(`${error.message}`); } // Then upload existing file From dd0ddf29091e7dc81f200295535d29c6e6085ead Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Fri, 23 Feb 2024 16:11:13 -0500 Subject: [PATCH 03/14] midway fixining tests, not yet fixed Signed-off-by: Amber Torrise --- packages/cli/CHANGELOG.md | 2 ++ .../upload/dtp/DirToPds.handler.unit.test.ts | 15 ++++++++++++- .../zosfiles/upload/dtp/DirToPds.handler.ts | 21 +++++++++++-------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 0a5f781915..318b023c95 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes +- BugFix: Update error handling in zosfiles to resemble that in zosjobs. [#2062](https://github.com/zowe/zowe-cli/pull/2062) + - BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061) - BugFix: Updated engine to Node 16.7.0. [#2061](https://github.com/zowe/zowe-cli/pull/2061) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts index aba9173262..fb6143d36d 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts @@ -10,10 +10,15 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_PROFILE_MAP_ZOSMF_TSO, UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import * as DirToPdsHandler from "../../../../../src/zosfiles/upload/dtp/DirToPds.handler" describe("Upload dir-to-pds handler", () => { describe("process method", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + it("should upload a directory to a PDS if requested", async () => { // Require the handler and create a new instance const handlerReq = require("../../../../../src/zosfiles/upload/dtp/DirToPds.handler"); @@ -94,6 +99,10 @@ describe("Upload dir-to-pds handler", () => { expect(logMessage).toMatchSnapshot(); }); + // it("shouldn't attempt to upload a file that hasnt been found", async () => { + + // }) + it("should upload a directory to a PDS in binary format if requested", async () => { // Require the handler and create a new instance const handlerReq = require("../../../../../src/zosfiles/upload/dtp/DirToPds.handler"); @@ -102,6 +111,10 @@ describe("Upload dir-to-pds handler", () => { const dataSetName = "testing"; const binary = true; + // Mocks + const checkDirectoryExistenceSpy = jest.spyOn(DirToPdsHandler, "checkDirectoryExistence"); + checkDirectoryExistenceSpy.mockResolvedValue(); + // Vars populated by the mocked function let error; let apiMessage = ""; diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index 58368d5c10..1c6482e1ee 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -26,15 +26,7 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { const inputDir = commandParameters.arguments.inputdir; // Check directory existence and accessibility - try { - const dirStats = await fs.stat(inputDir); - if (!dirStats.isDirectory()) { - throw new Error(`${inputDir} is not a directory.`); - } - } catch (error) { - // If the directory does not exist, is not accessible, or is not a directory, throw an error - throw new Error(`${error.message}`); - } + await checkDirectoryExistence(inputDir); const status: ITaskWithStatus = { statusMessage: "Uploading directory to PDS", @@ -61,3 +53,14 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { } } +// Function to check directory existence and accessibility +export async function checkDirectoryExistence(directoryPath: string): Promise { + try { + const dirStats = await fs.stat(directoryPath); + if (!dirStats.isDirectory()) { + throw new Error(`${directoryPath} is not a directory.`); + } + } catch (error) { + throw new Error(`${error.message}`); + } +} From dc310025afb42c920256b1372c0e2311a5bdafa7 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Mon, 26 Feb 2024 15:39:31 -0500 Subject: [PATCH 04/14] debugging DirToPdc.handler.unit.test.ts Signed-off-by: Amber Torrise --- .../upload/dtp/DirToPds.handler.unit.test.ts | 24 ++---- .../zosfiles/upload/dtp/DirToPds.handler.ts | 77 ++++++++++--------- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts index fb6143d36d..fe7f5b09f8 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts @@ -10,19 +10,21 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_PROFILE_MAP_ZOSMF_TSO, UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; -import * as DirToPdsHandler from "../../../../../src/zosfiles/upload/dtp/DirToPds.handler" +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import DirToPdsHandler from "../../../../../src/zosfiles/upload/dtp/DirToPds.handler"; describe("Upload dir-to-pds handler", () => { describe("process method", () => { + let handler: DirToPdsHandler; beforeEach(() => { - jest.clearAllMocks(); + jest.resetAllMocks(); + handler = new DirToPdsHandler(); + jest.mock('../../../../../src/zosfiles/upload/dtp/DirToPds.handler', () => ({ + checkDirectoryExistence: jest.fn().mockResolvedValue(undefined) + })); }); it("should upload a directory to a PDS if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/dtp/DirToPds.handler"); - const handler = new handlerReq.default(); const inputdir = "test-dir"; const dataSetName = "testing"; @@ -104,17 +106,10 @@ describe("Upload dir-to-pds handler", () => { // }) it("should upload a directory to a PDS in binary format if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/dtp/DirToPds.handler"); - const handler = new handlerReq.default(); const inputdir = "test-dir"; const dataSetName = "testing"; const binary = true; - // Mocks - const checkDirectoryExistenceSpy = jest.spyOn(DirToPdsHandler, "checkDirectoryExistence"); - checkDirectoryExistenceSpy.mockResolvedValue(); - // Vars populated by the mocked function let error; let apiMessage = ""; @@ -191,9 +186,6 @@ describe("Upload dir-to-pds handler", () => { }); it("should upload a directory to a PDS in record format if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/dtp/DirToPds.handler"); - const handler = new handlerReq.default(); const inputdir = "test-dir"; const dataSetName = "testing"; const record = true; diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index 1c6482e1ee..120c1da0a1 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -1,14 +1,3 @@ -/* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ - import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage } from "@zowe/imperative"; import { IZosFilesResponse, Upload } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; @@ -24,43 +13,59 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { session: AbstractSession): Promise { const inputDir = commandParameters.arguments.inputdir; - - // Check directory existence and accessibility - await checkDirectoryExistence(inputDir); - const status: ITaskWithStatus = { statusMessage: "Uploading directory to PDS", percentComplete: 0, stageName: TaskStage.IN_PROGRESS }; - commandParameters.response.progress.startBar({task: status}); - const response = await Upload.dirToPds( - session, - inputDir, - commandParameters.arguments.dataSetName, - { - volume: commandParameters.arguments.volumeSerial, - binary: commandParameters.arguments.binary, - record: commandParameters.arguments.record, - encoding: commandParameters.arguments.encoding, - task: status, - responseTimeout: commandParameters.arguments.responseTimeout - } - ); + try { + // Check directory existence and accessibility + await this.checkDirectoryExistence(inputDir); + + status.statusMessage = "Uploading directory to PDS"; + commandParameters.response.progress.startBar({task: status}); - return response; + const response = await Upload.dirToPds( + session, + inputDir, + commandParameters.arguments.dataSetName, + { + volume: commandParameters.arguments.volumeSerial, + binary: commandParameters.arguments.binary, + record: commandParameters.arguments.record, + encoding: commandParameters.arguments.encoding, + task: status, + responseTimeout: commandParameters.arguments.responseTimeout + } + ); + status.statusMessage = "Upload complete"; + status.percentComplete = 100; + return response; + } catch (error) { + // Handle errors from directory check or upload + status.statusMessage = "Error during upload"; + commandParameters.response.console.error(`Error: ${error.message}`); + return { + success: false, + commandResponse: `Failed to upload directory to PDS: ${error.message}` + }; + } finally { + // Clean up or finalize tasks, such as ending a progress bar + commandParameters.response.progress.endBar(); + } } -} -// Function to check directory existence and accessibility -export async function checkDirectoryExistence(directoryPath: string): Promise { - try { + + /** + * Checks if the specified directory exists and is accessible + * @param directoryPath - Path to the directory to check + * @returns Promise + */ + private async checkDirectoryExistence(directoryPath: string): Promise { const dirStats = await fs.stat(directoryPath); if (!dirStats.isDirectory()) { throw new Error(`${directoryPath} is not a directory.`); } - } catch (error) { - throw new Error(`${error.message}`); } } From 2d4dca9cc3697a566ba800b95ed9f1afe595b6d0 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Mon, 26 Feb 2024 17:01:48 -0500 Subject: [PATCH 05/14] ty to fernando for helping me figure out issues mocking checkDirectoryExistence Signed-off-by: Amber Torrise --- .../upload/dtp/DirToPds.handler.unit.test.ts | 5 +---- .../zosfiles/upload/dtp/DirToPds.handler.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts index fe7f5b09f8..79d799cc59 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts @@ -12,16 +12,13 @@ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; import DirToPdsHandler from "../../../../../src/zosfiles/upload/dtp/DirToPds.handler"; - describe("Upload dir-to-pds handler", () => { describe("process method", () => { let handler: DirToPdsHandler; beforeEach(() => { jest.resetAllMocks(); handler = new DirToPdsHandler(); - jest.mock('../../../../../src/zosfiles/upload/dtp/DirToPds.handler', () => ({ - checkDirectoryExistence: jest.fn().mockResolvedValue(undefined) - })); + (handler as any).checkDirectoryExistence = jest.fn().mockResolvedValue(undefined); }); it("should upload a directory to a PDS if requested", async () => { diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index 120c1da0a1..9b82ef83e3 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -46,26 +46,26 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { // Handle errors from directory check or upload status.statusMessage = "Error during upload"; commandParameters.response.console.error(`Error: ${error.message}`); - return { - success: false, - commandResponse: `Failed to upload directory to PDS: ${error.message}` - }; + throw new Error(error.message); // Corrected line } finally { - // Clean up or finalize tasks, such as ending a progress bar + // Clean up commandParameters.response.progress.endBar(); } } - /** * Checks if the specified directory exists and is accessible * @param directoryPath - Path to the directory to check * @returns Promise */ private async checkDirectoryExistence(directoryPath: string): Promise { - const dirStats = await fs.stat(directoryPath); - if (!dirStats.isDirectory()) { - throw new Error(`${directoryPath} is not a directory.`); + try { + const dirStats = await fs.stat(directoryPath); + if (!dirStats.isDirectory()) { + throw new Error(`${directoryPath} is not a directory.`); + } + } catch (error) { + throw new Error(`Failed to access directory: ${error.message}`); } } } From 4b36b4b299f21f762fe6244eb339c1123a3fb726 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 10:31:26 -0500 Subject: [PATCH 06/14] fixing dirtopds handler and test Signed-off-by: Amber Torrise --- .../DirToPds.handler.unit.test.ts.snap | 90 +++++++++++++++---- .../zosfiles/upload/dtp/DirToPds.handler.ts | 4 +- 2 files changed, 74 insertions(+), 20 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap index cde03d8fc2..909bec8ef5 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap @@ -1,40 +1,94 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Upload dir-to-pds handler process method should upload a directory to a PDS if requested 1`] = `undefined`; +exports[`Upload dir-to-pds handler process method should upload a directory to a PDS if requested 1`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "test-dir", + "success": true, + "to": "testing", + }, + Object { + "from": "testfrom", + "success": false, + "to": "testto", + }, + Object { + "from": "dummy", + "success": undefined, + "to": "nowhere", + }, + ], + "commandResponse": "uploaded", + "success": false, +} +`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS if requested 2`] = `""`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS if requested 3`] = ` " -success: true -from:  test-dir -to:  testing - -" +uploaded" `; -exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in binary format if requested 1`] = `undefined`; +exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in binary format if requested 1`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "test-dir", + "success": true, + "to": "testing", + }, + Object { + "from": "testfrom", + "success": false, + "to": "testto", + }, + Object { + "from": "dummy", + "success": undefined, + "to": "nowhere", + }, + ], + "commandResponse": "uploaded", + "success": false, +} +`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in binary format if requested 2`] = `""`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in binary format if requested 3`] = ` " -success: true -from:  test-dir -to:  testing - -" +uploaded" `; -exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in record format if requested 1`] = `undefined`; +exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in record format if requested 1`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "test-dir", + "success": true, + "to": "testing", + }, + Object { + "from": "testfrom", + "success": false, + "to": "testto", + }, + Object { + "from": "dummy", + "success": undefined, + "to": "nowhere", + }, + ], + "commandResponse": "uploaded", + "success": false, +} +`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in record format if requested 2`] = `""`; exports[`Upload dir-to-pds handler process method should upload a directory to a PDS in record format if requested 3`] = ` " -success: true -from:  test-dir -to:  testing - -" +uploaded" `; diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index 9b82ef83e3..ed68af0c55 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -39,8 +39,8 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { responseTimeout: commandParameters.arguments.responseTimeout } ); - status.statusMessage = "Upload complete"; - status.percentComplete = 100; + status.statusMessage = "Uploading directory to PDS"; + status.percentComplete = 0; return response; } catch (error) { // Handle errors from directory check or upload From 0dd7e2aef3bd9654e1036200edd821c77d3f9672 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 14:21:09 -0500 Subject: [PATCH 07/14] failing integration tests Signed-off-by: Amber Torrise --- .../upload/dtp/DirToPds.handler.unit.test.ts | 65 +++++++++-- .../DirToPds.handler.unit.test.ts.snap | 9 ++ .../ftds/FileToDataSet.handler.unit.test.ts | 101 ++++++++++++------ .../FileToDataSet.handler.unit.test.ts.snap | 61 +++++------ .../zosfiles/upload/dtp/DirToPds.handler.ts | 8 +- .../upload/ftds/FileToDataSet.handler.ts | 59 +++++++--- 6 files changed, 208 insertions(+), 95 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts index 79d799cc59..31ff242c42 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts @@ -15,6 +15,8 @@ import DirToPdsHandler from "../../../../../src/zosfiles/upload/dtp/DirToPds.han describe("Upload dir-to-pds handler", () => { describe("process method", () => { let handler: DirToPdsHandler; + const inputdir = "test-dir"; + const dataSetName = "testing"; beforeEach(() => { jest.resetAllMocks(); handler = new DirToPdsHandler(); @@ -22,9 +24,6 @@ describe("Upload dir-to-pds handler", () => { }); it("should upload a directory to a PDS if requested", async () => { - const inputdir = "test-dir"; - const dataSetName = "testing"; - // Vars populated by the mocked function let error; let apiMessage = ""; @@ -98,13 +97,63 @@ describe("Upload dir-to-pds handler", () => { expect(logMessage).toMatchSnapshot(); }); - // it("shouldn't attempt to upload a file that hasnt been found", async () => { + it("should not attempt to upload a dir that hasn't been found", async () => { + (handler as any).checkDirectoryExistence = jest.fn().mockRejectedValue(new Error("Failed to access directory")); + // Vars populated by the mocked function + let error; + let apiMessage = ""; + let jsonObj; + let logMessage = ""; + + // Mock the submit JCL function + Upload.dirToPds = jest.fn(); - // }) + try { + // Invoke the handler with a full set of mocked arguments and response functions + await handler.process({ + arguments: { + $0: "fake", + _: ["fake"], + inputdir, + dataSetName, + ...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; + }), + error: jest.fn((logArgs) => { + logMessage += "\n" + logArgs; + }) + }, + progress: { + startBar: jest.fn(), + endBar: jest.fn() + } + } + } as any); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toContain("Failed to access directory"); + expect(Upload.dirToPds).toHaveBeenCalledTimes(0); + expect(jsonObj).toMatchSnapshot(); + expect(apiMessage).toMatchSnapshot(); + expect(logMessage).toMatchSnapshot(); + }); it("should upload a directory to a PDS in binary format if requested", async () => { - const inputdir = "test-dir"; - const dataSetName = "testing"; const binary = true; // Vars populated by the mocked function @@ -183,8 +232,6 @@ describe("Upload dir-to-pds handler", () => { }); it("should upload a directory to a PDS in record format if requested", async () => { - const inputdir = "test-dir"; - const dataSetName = "testing"; const record = true; // Vars populated by the mocked function diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap index 909bec8ef5..b751b6f0fc 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/__snapshots__/DirToPds.handler.unit.test.ts.snap @@ -1,5 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Upload dir-to-pds handler process method should not attempt to upload a dir that hasn't been found 1`] = `undefined`; + +exports[`Upload dir-to-pds handler process method should not attempt to upload a dir that hasn't been found 2`] = `""`; + +exports[`Upload dir-to-pds handler process method should not attempt to upload a dir that hasn't been found 3`] = ` +" +Error: Failed to access directory" +`; + exports[`Upload dir-to-pds handler process method should upload a directory to a PDS if requested 1`] = ` Object { "apiResponse": Array [ diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts index cddbc54373..0c7d993f07 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts @@ -11,16 +11,19 @@ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import FileToDataSet from "../../../../../src/zosfiles/upload/ftds/FileToDataSet.handler"; describe("Upload file-to-data-set handler", () => { describe("process method", () => { + let handler: FileToDataSet; + const inputfile = "test-file"; + const dataSetName = "testing"; + beforeEach(() => { + jest.resetAllMocks(); + handler = new FileToDataSet(); + (handler as any).checkFileExistence = jest.fn().mockResolvedValue(undefined); + }); it("should upload a file to a data set if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/ftds/FileToDataSet.handler"); - const handler = new handlerReq.default(); - const inputfile = "test-file"; - const dataSetName = "testing"; - // Vars populated by the mocked function let error; let apiMessage = ""; @@ -35,7 +38,9 @@ describe("Upload file-to-data-set handler", () => { success: true, commandResponse: "uploaded", apiResponse: [ - {success: true, from: inputfile, to: dataSetName} + {success: true, from: inputfile, to: dataSetName}, + {success: false, from: "testfrom", to: "testto"}, + {success: undefined, from: "dummy", to: "nowhere"} ] }; }); @@ -93,11 +98,6 @@ describe("Upload file-to-data-set handler", () => { }); it("should upload a file to a data set in binary format if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/ftds/FileToDataSet.handler"); - const handler = new handlerReq.default(); - const inputfile = "test-file"; - const dataSetName = "testing"; const binary = true; // Vars populated by the mocked function @@ -174,11 +174,6 @@ describe("Upload file-to-data-set handler", () => { }); it("should upload a file to a data set in record format if requested", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/ftds/FileToDataSet.handler"); - const handler = new handlerReq.default(); - const inputfile = "test-file"; - const dataSetName = "testing"; const record = true; // Vars populated by the mocked function @@ -254,13 +249,7 @@ describe("Upload file-to-data-set handler", () => { expect(logMessage).toMatchSnapshot(); }); - it("should display error when upload file to data set", async () => { - // Require the handler and create a new instance - const handlerReq = require("../../../../../src/zosfiles/upload/ftds/FileToDataSet.handler"); - const handler = new handlerReq.default(); - const inputfile = "test-file"; - const dataSetName = "testing"; - + it("should display error when uploading found file to data set", async () => { // Vars populated by the mocked function let error; let apiMessage = ""; @@ -331,13 +320,63 @@ describe("Upload file-to-data-set handler", () => { }); expect(jsonObj).toMatchSnapshot(); expect(apiMessage).toMatchSnapshot(); - expect(logMessage).toMatch(/success:.*false/); - expect(logMessage).toMatch(/from:.*test-file/); - expect(logMessage).toMatch(/file_to_upload:.*1/); - expect(logMessage).toMatch(/success:.*0/); - expect(logMessage).toMatch(/error:.*1/); - expect(logMessage).toMatch(/skipped:.*0/); - expect(logMessage).toMatch(/uploaded/); + expect(logMessage).toMatchSnapshot(); + }); + + it("should not attempt to upload a file that hasn't been found", async () => { + (handler as any).checkFileExistence = jest.fn().mockRejectedValue(new Error("File does not exist or is not accessible")); + // Vars populated by the mocked function + let error; + let apiMessage = ""; + let jsonObj; + let logMessage = ""; + + // Mock the submit JCL function + Upload.fileToDataset = jest.fn(); + + try { + // Invoke the handler with a full set of mocked arguments and response functions + await handler.process({ + arguments: { + $0: "fake", + _: ["fake"], + inputfile, + dataSetName, + ...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; + }), + error: jest.fn((logArgs) => { + logMessage += "\n" + logArgs; + }) + }, + progress: { + startBar: jest.fn(), + endBar: jest.fn() + } + } + } as any); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toContain("File does not exist or is not accessible"); + expect(Upload.fileToDataset).toHaveBeenCalledTimes(0); + expect(jsonObj).toMatchSnapshot(); + expect(apiMessage).toMatchSnapshot(); + expect(logMessage).toMatchSnapshot(); }); }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap index 1cd2b1490a..9aaa562c54 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/__snapshots__/FileToDataSet.handler.unit.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Upload file-to-data-set handler process method should display error when upload file to data set 1`] = ` +exports[`Upload file-to-data-set handler process method should display error when uploading found file to data set 1`] = ` Object { "apiResponse": Array [ Object { @@ -14,7 +14,21 @@ Object { } `; -exports[`Upload file-to-data-set handler process method should display error when upload file to data set 2`] = `""`; +exports[`Upload file-to-data-set handler process method should display error when uploading found file to data set 2`] = `""`; + +exports[`Upload file-to-data-set handler process method should display error when uploading found file to data set 3`] = ` +" +uploaded" +`; + +exports[`Upload file-to-data-set handler process method should not attempt to upload a file that hasn't been found 1`] = `undefined`; + +exports[`Upload file-to-data-set handler process method should not attempt to upload a file that hasn't been found 2`] = `""`; + +exports[`Upload file-to-data-set handler process method should not attempt to upload a file that hasn't been found 3`] = ` +" +Error: File does not exist or is not accessible" +`; exports[`Upload file-to-data-set handler process method should upload a file to a data set if requested 1`] = ` Object { @@ -24,6 +38,16 @@ Object { "success": true, "to": "testing", }, + Object { + "from": "testfrom", + "success": false, + "to": "testto", + }, + Object { + "from": "dummy", + "success": undefined, + "to": "nowhere", + }, ], "commandResponse": "uploaded", "success": true, @@ -34,17 +58,6 @@ exports[`Upload file-to-data-set handler process method should upload a file to exports[`Upload file-to-data-set handler process method should upload a file to a data set if requested 3`] = ` " -success: true -from:  test-file -to:  testing - - -file_to_upload: 1 -success:  1 -error:  0 -skipped:  0 - - uploaded" `; @@ -66,17 +79,6 @@ exports[`Upload file-to-data-set handler process method should upload a file to exports[`Upload file-to-data-set handler process method should upload a file to a data set in binary format if requested 3`] = ` " -success: true -from:  test-file -to:  testing - - -file_to_upload: 1 -success:  1 -error:  0 -skipped:  0 - - uploaded" `; @@ -98,16 +100,5 @@ exports[`Upload file-to-data-set handler process method should upload a file to exports[`Upload file-to-data-set handler process method should upload a file to a data set in record format if requested 3`] = ` " -success: true -from:  test-file -to:  testing - - -file_to_upload: 1 -success:  1 -error:  0 -skipped:  0 - - uploaded" `; diff --git a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts index ed68af0c55..f3b2a43e3d 100644 --- a/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts +++ b/packages/cli/src/zosfiles/upload/dtp/DirToPds.handler.ts @@ -13,6 +13,7 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { session: AbstractSession): Promise { const inputDir = commandParameters.arguments.inputdir; + const dataSetName = commandParameters.arguments.dataSetName; const status: ITaskWithStatus = { statusMessage: "Uploading directory to PDS", percentComplete: 0, @@ -29,7 +30,7 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { const response = await Upload.dirToPds( session, inputDir, - commandParameters.arguments.dataSetName, + dataSetName, { volume: commandParameters.arguments.volumeSerial, binary: commandParameters.arguments.binary, @@ -39,16 +40,13 @@ export default class DirToPdsHandler extends ZosFilesBaseHandler { responseTimeout: commandParameters.arguments.responseTimeout } ); - status.statusMessage = "Uploading directory to PDS"; - status.percentComplete = 0; return response; } catch (error) { // Handle errors from directory check or upload status.statusMessage = "Error during upload"; commandParameters.response.console.error(`Error: ${error.message}`); - throw new Error(error.message); // Corrected line + throw new Error(error.message); } finally { - // Clean up commandParameters.response.progress.endBar(); } } diff --git a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts index 15f94e7a42..89f9f7c510 100644 --- a/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftds/FileToDataSet.handler.ts @@ -13,6 +13,7 @@ import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage } from import { IZosFilesResponse, Upload } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; import { promises as fs } from 'fs'; + /** * Handler to upload content from a file to a data set * @export @@ -23,25 +24,53 @@ export default class FileToDataSetHandler extends ZosFilesBaseHandler { const inputFile = commandParameters.arguments.inputfile; const dataSetName = commandParameters.arguments.dataSetName; - - // Check for file's existence - try { - await fs.access(inputFile, fs.constants.F_OK | fs.constants.R_OK); - } catch (error) { - throw new Error(`${error.message}`); - } - - // Then upload existing file - const task: ITaskWithStatus = { - percentComplete: 0, + const status: ITaskWithStatus = { statusMessage: "Uploading to data set", + percentComplete: 0, stageName: TaskStage.IN_PROGRESS }; - commandParameters.response.progress.startBar({task}); - const response = await Upload.fileToDataset(session, inputFile, dataSetName, { - }); + try { + // Check for file's existence and accessibility + await this.checkFileExistence(inputFile); - return response; + commandParameters.response.progress.startBar({task: status}); + + const response = await Upload.fileToDataset( + session, + inputFile, + dataSetName, + { + volume: commandParameters.arguments.volumeSerial, + binary: commandParameters.arguments.binary, + record: commandParameters.arguments.record, + encoding: commandParameters.arguments.encoding, + task: status, + responseTimeout: commandParameters.arguments.responseTimeout + } + ); + return response; + } catch (error) { + // Handle errors from directory check or upload + status.statusMessage = "Error during upload"; + commandParameters.response.console.error(`Error: ${error.message}`); + throw new Error(error.message); + } finally { + // Clean up + commandParameters.response.progress.endBar(); + } + } + + /** + * Checks if the specified file exists and is accessible + * @param filePath - Path to the file to check + * @returns Promise + */ + private async checkFileExistence(filePath: string): Promise { + try { + await fs.access(filePath, fs.constants.F_OK | fs.constants.R_OK); + } catch (error) { + throw new Error(`File does not exist or is not accessible: ${filePath}`); + } } } \ No newline at end of file From b7607f68585671ff2a961e274cf9684ac18e5dcd Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 14:38:25 -0500 Subject: [PATCH 08/14] might have just done the wrong thing to fix changelog Signed-off-by: Amber Torrise --- packages/cli/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 318b023c95..4ee3e6fd09 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -6,12 +6,13 @@ All notable changes to the Zowe CLI package will be documented in this file. - BugFix: Update error handling in zosfiles to resemble that in zosjobs. [#2062](https://github.com/zowe/zowe-cli/pull/2062) +## `8.0.0-next.202402271901` - BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061) - BugFix: Updated engine to Node 16.7.0. [#2061](https://github.com/zowe/zowe-cli/pull/2061) ## `8.0.0-next.202402211923` -- Enhancement: Added new `zowe zos-jobs search job` command, which allows the user to search spool files for a specified string or regular expresion. +- Enhancement: Added new `zowe zos-jobs search job` command, which allows the user to search spool files for a specified string or regular expression. - BugFix: Updated dependencies for technical currency. [#2057](https://github.com/zowe/zowe-cli/pull/2057) ## `8.0.0-next.202402132108` From eb472e1c143f1a548c7898f5001276fc150497a3 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 14:56:04 -0500 Subject: [PATCH 09/14] fix changelog? Signed-off-by: Amber Torrise --- packages/cli/CHANGELOG.md | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 38f5284a28..767de3fa17 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe CLI package will be documented in this file. -## `8.0.0-next.202402261705` +## Recent Changes - BugFix: Update error handling in zosfiles to resemble that in zosjobs. [#2062](https://github.com/zowe/zowe-cli/pull/2062) @@ -12,7 +12,7 @@ All notable changes to the Zowe CLI package will be documented in this file. ## `8.0.0-next.202402211923` -- Enhancement: Added new `zowe zos-jobs search job` command, which allows the user to search spool files for a specified string or regular expression. +- Enhancement: Added new `zowe zos-jobs search job` command, which allows the user to search spool files for a specified string or regular expresion. - BugFix: Updated dependencies for technical currency. [#2057](https://github.com/zowe/zowe-cli/pull/2057) ## `8.0.0-next.202402132108` @@ -76,22 +76,6 @@ LTS Breaking: Removed the following previously deprecated items: [#1981](https:/ - Major: First major version bump for V3 -## `7.23.3` - -- BugFix: Fixed race condition in `config convert-profiles` command that may fail to delete secure values for old profiles - -## `7.23.2` - -- BugFix: Resolved technical currency by updating `socks` transitive dependency - -## `7.23.1` - -- Enhancement: Adding `--binary` and `--encoding` options to `zosfiles edit` to zowe V2 - -## `7.23.0` - -- BugFix: Update zos-files copy dsclp system tests to include large mock files. - ## `7.22.0` - Enhancement: Hid the progress bar if `CI` environment variable is set, or if `FORCE_COLOR` environment variable is set to `0`. [#1845](https://github.com/zowe/zowe-cli/issues/1845) From 630c93deb2400523325694c45bee38af325991c0 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 15:19:05 -0500 Subject: [PATCH 10/14] making integration fixes that might be related to OS Signed-off-by: Amber Torrise --- .../upload/dtp/cli.files.upload.dtp.integration.test.ts | 2 +- .../upload/ftds/cli.files.upload.ftds.integration.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts index c647e779ec..7440e6a96a 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts @@ -62,7 +62,7 @@ describe("Upload directory to PDS", () => { it("should fail when local directory does not exist", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtp.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localDirThatDoesNotExist", "mf.data.set"]); - expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory, lstat"); + expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); expect(stripNewLines(response.stderr.toString())).toContain("localDirThatDoesNotExist"); }); diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts index 0cff72a34b..a013ce18eb 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts @@ -50,7 +50,7 @@ describe("Upload file to data set", () => { it("should fail when local file does not exist", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_ftds.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localFileThatDoesNotExist", "data.set.name"]); - expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory, lstat"); + expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); expect(stripNewLines(response.stderr.toString())).toContain("localFileThatDoesNotExist"); }); From 24ec58742de3f24f0e5e4bf12b226ec97ba68628 Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 15:38:20 -0500 Subject: [PATCH 11/14] updating integration tests to expect what is thrown Signed-off-by: Amber Torrise --- .../upload/dtp/cli.files.upload.dtp.integration.test.ts | 2 +- .../upload/ftds/cli.files.upload.ftds.integration.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts index 7440e6a96a..bed54b1865 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts @@ -62,7 +62,7 @@ describe("Upload directory to PDS", () => { it("should fail when local directory does not exist", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtp.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localDirThatDoesNotExist", "mf.data.set"]); - expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); + expect(stripNewLines(response.stderr.toString())).toContain("File does not exist or is not accessible"); expect(stripNewLines(response.stderr.toString())).toContain("localDirThatDoesNotExist"); }); diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts index a013ce18eb..1946822813 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/ftds/cli.files.upload.ftds.integration.test.ts @@ -50,7 +50,7 @@ describe("Upload file to data set", () => { it("should fail when local file does not exist", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_ftds.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localFileThatDoesNotExist", "data.set.name"]); - expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); + expect(stripNewLines(response.stderr.toString())).toContain("File does not exist or is not accessible"); expect(stripNewLines(response.stderr.toString())).toContain("localFileThatDoesNotExist"); }); From 91b38b8c162fe5ff53ea8fe87cedaf08e0e6994a Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 27 Feb 2024 15:53:00 -0500 Subject: [PATCH 12/14] fix Signed-off-by: Amber Torrise --- .../upload/dtp/cli.files.upload.dtp.integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts index bed54b1865..7440e6a96a 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/dtp/cli.files.upload.dtp.integration.test.ts @@ -62,7 +62,7 @@ describe("Upload directory to PDS", () => { it("should fail when local directory does not exist", async () => { const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtp.sh"); const response = runCliScript(shellScript, TEST_ENVIRONMENT, ["localDirThatDoesNotExist", "mf.data.set"]); - expect(stripNewLines(response.stderr.toString())).toContain("File does not exist or is not accessible"); + expect(stripNewLines(response.stderr.toString())).toContain("no such file or directory"); expect(stripNewLines(response.stderr.toString())).toContain("localDirThatDoesNotExist"); }); From 61aa4ebffcb8ae0dc2cd441a70ac7f2dca36b378 Mon Sep 17 00:00:00 2001 From: Amber Torrise <112635587+ATorrise@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:08:50 -0500 Subject: [PATCH 13/14] Update CHANGELOG.md Signed-off-by: Amber Torrise <112635587+ATorrise@users.noreply.github.com> --- packages/cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 767de3fa17..9eb19f2839 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to the Zowe CLI package will be documented in this file. - BugFix: Update error handling in zosfiles to resemble that in zosjobs. [#2062](https://github.com/zowe/zowe-cli/pull/2062) -## `8.0.0-next.202402271901` +## `8.0.0-next.202402261705` - BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061) - BugFix: Updated engine to Node 16.7.0. [#2061](https://github.com/zowe/zowe-cli/pull/2061) From 2afdebc36c085d0f204313df84cdf6f866d82312 Mon Sep 17 00:00:00 2001 From: Amber Torrise <112635587+ATorrise@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:47:25 -0500 Subject: [PATCH 14/14] not sure how changelog deletions were made Signed-off-by: Amber Torrise <112635587+ATorrise@users.noreply.github.com> --- packages/cli/CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 9eb19f2839..5c52fac038 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -75,7 +75,22 @@ LTS Breaking: Removed the following previously deprecated items: [#1981](https:/ ## `8.0.0-next.202311132045` - Major: First major version bump for V3 + +## `7.23.3` + +- BugFix: Fixed race condition in `config convert-profiles` command that may fail to delete secure values for old profiles + +## `7.23.2` + +- BugFix: Resolved technical currency by updating `socks` transitive dependency + +## `7.23.1` + +- Enhancement: Adding `--binary` and `--encoding` options to `zosfiles edit` to zowe V2 + +## `7.23.0` +- BugFix: Update zos-files copy dsclp system tests to include large mock files. ## `7.22.0` - Enhancement: Hid the progress bar if `CI` environment variable is set, or if `FORCE_COLOR` environment variable is set to `0`. [#1845](https://github.com/zowe/zowe-cli/issues/1845)