diff --git a/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts index cd8ae968ad..0da5485d15 100644 --- a/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts @@ -66,16 +66,16 @@ describe("List active workflow details cli system tests", () => { afterAll(async () => { // deleting wf instance const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { try { await DeleteWorkflow.deleteWorkflow(REAL_SESSION, element.workflowKey); } catch { /* Do nothing */ } } - }); + }; }); describe("Success Scenarios", () => { - it("Should list active workflow details using wf key.", async () => { + it("Should list active workflow details using wf key.", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_key_details.sh", testEnvironment, [wfKey]); expect(response.stderr.toString()).toBe(""); @@ -83,7 +83,7 @@ describe("List active workflow details cli system tests", () => { expect(response.stdout.toString()).toContain("Workflow Details"); }); - it("Should list active workflow details using wf name.", async () => { + it("Should list active workflow details using wf name.", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_name_details.sh", testEnvironment, [wfName]); expect(response.stderr.toString()).toBe(""); @@ -92,14 +92,14 @@ describe("List active workflow details cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the workflow does not exist", async () => { + it("Should throw error if the workflow does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_key_details.sh", testEnvironment, [fakeDefFile]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("does not exist."); }); - it("Should throw error if the workflow name does not exist", async () => { + it("Should throw error if the workflow name does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_name_details.sh", testEnvironment, [fakeDefFile]); expect(response.status).toBe(1); diff --git a/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts index 2bacd0116d..7769bbc0cf 100644 --- a/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts @@ -64,16 +64,16 @@ describe("List workflow cli system tests", () => { } }); describe("Success Scenarios", () => { - it("Should return list of workflows in zOSMF.", async () => { + it("Should return list of workflows in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", testEnvironment, [wfName]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(`${wfName}`); }); - it("Should return a message if search does not match any existing workflows", async () => { + it("Should return a message if search does not match any existing workflows", () => { const fakeName = `${wfName}${wfName}${wfName}`; - const response = await runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", testEnvironment, [fakeName]); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("No workflows match the requested querry"); diff --git a/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts index 06b0c03045..67d2d79e0d 100644 --- a/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts @@ -52,23 +52,23 @@ describe("Retrieve workflow definition cli system tests", () => { testEnvironment.resources.files.push(definitionFile); }); describe("Success Scenarios", () => { - it("Should return the details of a workflow definition file.", async () => { + it("Should return the details of a workflow definition file.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [`/${defaultSystem.unix.testdir.toLocaleLowerCase()}/${uniqueFileName}.xml`]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(`success": true`); }); - it("Should return a message if search does not match any existing files", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", + it("Should return a message if search does not match any existing files", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [`/${defaultSystem.unix.testdir.toLocaleLowerCase()}/${uniqueFileName}`]); expect(response.status).toBe(1); expect(response.stdout.toString()).toContain("not found or cannot be accessed."); }); - it("Should return a message if search is for a diectory", async () => { + it("Should return a message if search is for a diectory", () => { const fakeName = `/${defaultSystem.unix.testdir.toLocaleLowerCase()}`; - const response = await runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [fakeName]); expect(response.status).toBe(1); expect(response.stdout.toString()).toContain("is not a UNIX file"); diff --git a/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts index 53727050d4..002a777e43 100644 --- a/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts @@ -64,7 +64,7 @@ describe("Create workflow cli system tests", () => { afterEach(async () => { let error; const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { wfKey = element.workflowKey; try { @@ -73,25 +73,25 @@ describe("Create workflow cli system tests", () => { error = err; } } - }); + }; }); - it("Should create workflow in zOSMF.", async () => { + it("Should create workflow in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", + it("Should throw error if workflow with the same name already exists", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner, "--overwrite"]); @@ -101,7 +101,7 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the uss file does not exist", async () => { + it("Should throw error if the uss file does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, fakeDefFile, system, owner]); expect(response.status).toBe(1); @@ -113,7 +113,7 @@ describe("Create workflow cli system tests", () => { describe("Success Scenarios", () => { afterEach(async () =>{ let error; - const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); + const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); let deleteWorkflow: any; for (deleteWorkflow of response.workflows) { if(deleteWorkflow.workflowName===wfName){ @@ -126,25 +126,25 @@ describe("Create workflow cli system tests", () => { } } }); - it("Should create workflow in zOSMF.", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should create workflow in zOSMF.", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should throw error if workflow with the same name already exists", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner, "--overwrite"]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); @@ -152,8 +152,8 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the local file does not exist", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should throw error if the local file does not exist", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, fakeLocalFile, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("no such file or directory"); @@ -179,7 +179,7 @@ describe("Create workflow cli system tests", () => { afterEach(async () => { let error; const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { wfKey = element.workflowKey; try { @@ -188,25 +188,25 @@ describe("Create workflow cli system tests", () => { error = err; } } - }); + }; }); - it("Should create workflow in zOSMF.", async () => { + it("Should create workflow in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", + it("Should throw error if workflow with the same name already exists", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + const createWf = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner, "--overwrite"]); @@ -216,7 +216,7 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the dataset does not exist", async () => { + it("Should throw error if the dataset does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, fakeDefFile, system, owner]); expect(response.status).toBe(1); diff --git a/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts index 875a9c6748..699a9d2e84 100644 --- a/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts @@ -85,42 +85,42 @@ describe("Start workflow cli system tests", () => { Imperative.console.info(err); } }); - it("Should start full workflow using wf key in zOSMF.", async () => { + it("Should start full workflow using wf key in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_full.sh", testEnvironment, [wfKey, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow"); }); - it("Should start full workflow using wf Name in zOSMF.", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_full.sh", + it("Should start full workflow using wf Name in zOSMF.", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_full.sh", testEnvironment, [wfName, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow"); }); - it("Should start one workflow using wf Key and step.", async () => { + it("Should start one workflow using wf Key and step.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_step.sh", testEnvironment, [stepName, wfKey, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow using wf Name and step.", async () => { + it("Should start one workflow using wf Name and step.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_step.sh", testEnvironment, [stepName, wfName, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow step using wf Key.", async () => { + it("Should start one workflow step using wf Key.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_step_plus_following.sh", testEnvironment, [stepName, wfKey, resolveConflict, "--perform-following-steps"]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow step using wf Name.", async () => { + it("Should start one workflow step using wf Name.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_step_plus_following.sh", testEnvironment, [stepName, wfName, resolveConflict, "--perform-following-steps"]); expect(response.stderr.toString()).toBe(""); diff --git a/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts index 93462e7af2..dfaa85ddd0 100644 --- a/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts @@ -32,9 +32,12 @@ describe("Invoke AMS CLI", () => { // replace high-level-qualifier with user value const AMSStatement = fs.readFileSync(templateFile).toString(); const updatedStatement = TextUtils.renderWithMustache(AMSStatement, {DSN: dsname, VOL: volume}); - fs.writeFileSync(templateFile + ".temp", updatedStatement); - testEnvironment.resources.localFiles.push(templateFile + ".temp"); - return templateFile + ".temp"; + const filename = templateFile + ".temp"; + fs.writeFileSync(filename, updatedStatement); + if (!testEnvironment.resources.localFiles.includes(filename)) { + testEnvironment.resources.localFiles.push(filename); + } + return filename; } // Create the unique test environment diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts index 99af5f7f6f..1b44460015 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts @@ -260,6 +260,10 @@ describe("Upload directory to USS", () => { }); describe("Scenarios using the .zosattributes file", () => { + afterEach(async () => { + await deleteFiles(REAL_SESSION, ussname); + }); + it("should ignore files marked with a -", async () => { const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir/dir_with_ignored_files"); testSuccessfulUpload(localDirName); diff --git a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts index ecb0633e63..f65a035fde 100644 --- a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts @@ -20,7 +20,6 @@ let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; let defaultSystem: ITestPropertiesSchema; let ussname: string; -let filename: string; describe("Delete a USS File", () => { @@ -31,7 +30,7 @@ describe("Delete a USS File", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}`; + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFileSingle`.replace(/\./g, ""); }); afterAll(async () => { @@ -42,9 +41,8 @@ describe("Delete a USS File", () => { beforeEach(async () => { let error; let response; - filename = `${ussname}.aTestUssFileSingle`.replace(/\./g, ""); try { - response = await Create.uss(REAL_SESSION, filename, "file"); + response = await Create.uss(REAL_SESSION, ussname, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -56,7 +54,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -74,7 +72,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, undefined, {responseTimeout: 5}); + response = await Delete.ussFile(REAL_SESSION, ussname, undefined, {responseTimeout: 5}); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -92,7 +90,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, "//"+filename); + response = await Delete.ussFile(REAL_SESSION, "//"+ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -153,7 +151,7 @@ describe("Delete a USS File - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim() + ".Enco#ed"}`; + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFileSingle`.replace(/\./g, ""); }); afterAll(async () => { @@ -163,9 +161,8 @@ describe("Delete a USS File - encoded", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - filename = `${ussname}.aTestUssFileSingle`.replace(/\./g, ""); try { - await Create.uss(REAL_SESSION, filename, "file"); + await Create.uss(REAL_SESSION, ussname, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -177,7 +174,7 @@ describe("Delete a USS File - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -195,7 +192,7 @@ describe("Delete a USS File - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, "//"+filename); + response = await Delete.ussFile(REAL_SESSION, "//"+ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -219,7 +216,7 @@ describe("Delete USS Directory", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFolderDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFolderDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -231,7 +228,7 @@ describe("Delete USS Directory", () => { let error; let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + response = await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -243,7 +240,7 @@ describe("Delete USS Directory", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -258,21 +255,6 @@ describe("Delete USS Directory", () => { }); describe("Failure scenarios", () => { - beforeAll(async () => { - let error; - let response; - // ussname = ussname.replace(/\./g, ""); - filename = `${defaultSystem.unix.testdir}/${ussname}`; - try { - response = await Create.uss(REAL_SESSION, filename, "directory"); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - afterAll(async () => { - await TestEnvironment.cleanUp(testEnvironment); - }); it("should display proper error message when called with invalid directory name", async () => { let error; let response; @@ -318,7 +300,7 @@ describe("Delete USS Directory - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.Enco#ed.aTestUssFolderDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFolderDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -330,7 +312,7 @@ describe("Delete USS Directory - encoded", () => { let error; let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + response = await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -342,7 +324,7 @@ describe("Delete USS Directory - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -366,7 +348,7 @@ describe("Delete USS Directory with children", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFileDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFileDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -378,13 +360,13 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + response = await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - response = await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + response = await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -395,7 +377,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, true); + response = await Delete.ussFile(REAL_SESSION, ussname, true); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -412,13 +394,13 @@ describe("Delete USS Directory with children", () => { beforeEach(async () => { let error; try { - await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -437,7 +419,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -452,7 +434,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, false); + response = await Delete.ussFile(REAL_SESSION, ussname, false); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -474,7 +456,7 @@ describe("Delete USS Directory with children - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.Enco#ed.aTestUssFileDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFileDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -485,13 +467,13 @@ describe("Delete USS Directory with children - encoded", () => { beforeEach(async () => { let error; try { - await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -502,7 +484,7 @@ describe("Delete USS Directory with children - encoded", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, true); + response = await Delete.ussFile(REAL_SESSION, ussname, true); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; diff --git a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts index 5e8e361bc9..a1daccc33d 100644 --- a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts @@ -48,9 +48,12 @@ describe("Invoke AMS", () => { // replace DSN with unique data set name const AMSStatement = fs.readFileSync(templateFile).toString(); const updatedStatement = TextUtils.renderWithMustache(AMSStatement, {DSN: dsname, VOL: volume}); - fs.writeFileSync(templateFile + ".temp", updatedStatement); - testEnvironment.resources.localFiles.push(templateFile + ".temp"); - return templateFile + ".temp"; + const filename = templateFile + ".temp"; + fs.writeFileSync(filename, updatedStatement); + if (!testEnvironment.resources.localFiles.includes(filename)) { + testEnvironment.resources.localFiles.push(filename); + } + return filename; } it("should create and delete a VSAM data set from command statement in files", async () => { diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index 00f1f56950..e0797df365 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -941,14 +941,14 @@ describe("Upload a local directory to USS directory", () => { Imperative.console.info("Using ussfile:" + ussname); }); - beforeEach(() => { - tempUssname = null; - }); - afterAll(async () => { await TestEnvironment.cleanUp(testEnvironment); }); + beforeEach(() => { + tempUssname = null; + }); + afterEach(async () => { await deleteFiles(REAL_SESSION, tempUssname ?? ussname); });