Skip to content

Commit

Permalink
fixing runCliScrip import and TestEnvironment.cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: ATorrise <amber.torrise@broadcom.com>
  • Loading branch information
ATorrise committed Sep 19, 2024
1 parent 5e40b67 commit 2d1c9be
Show file tree
Hide file tree
Showing 59 changed files with 124 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as nodePath from "path";
import * as yaml from "js-yaml";
import { v4 as uuidv4 } from "uuid";
import { AbstractSession, ImperativeError, ImperativeExpect,
IO, Logger, LoggingConfigurer, ProfileInfo, Session, TextUtils } from "@zowe/imperative";
IO, Logger, LoggingConfigurer, Session, TextUtils } from "@zowe/imperative";
import { ISetupEnvironmentParms } from "./doc/parms/ISetupEnvironmentParms";
import { ITestEnvironment } from "./doc/response/ITestEnvironment";
import { TempTestProfiles } from "./TempTestProfiles";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @export
* @interface ITestEnvironment
*/
export interface ITestEnvironment<ITestPropertiesSchema> {
export interface ITestEnvironment<TestPropertiesSchema> {
/**
* The working directory for your test environment. It is a unique (uuid) area where your tests can create
* their home folders (for imperative, etc.) and you can use the area as scratch for any files, etc. that
Expand All @@ -29,10 +29,10 @@ export interface ITestEnvironment<ITestPropertiesSchema> {
* in the case that no system test properties were configured or could be loaded.
*
* Not present if skipProperties is specified on ISetupEnvironmentParms
* @type {ITestPropertiesSchema}
* @type {TestPropertiesSchema}
* @memberof ITestEnvironment
*/
systemTestProperties: ITestPropertiesSchema;
systemTestProperties: TestPropertiesSchema;

/**
* Set of environmental variables (such as profile/logging home directory)
Expand All @@ -55,4 +55,4 @@ export interface ITestEnvironment<ITestPropertiesSchema> {
* Was the plugin installed in the working directory
*/
pluginInstalled?: boolean;
}
}
38 changes: 35 additions & 3 deletions __tests__/__src__/environment/TestEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import * as nodePath from "path";
import { AbstractSession, Imperative, Session } from "@zowe/imperative";

import { ITestPropertiesSchema } from "../properties/ITestPropertiesSchema";
import { ISetupEnvironmentParms, TestEnvironment as BaseTestEnvironment, TempTestProfiles } from "../../__packages__/cli-test-utils";
import { ISetupEnvironmentParms, TestEnvironment as BaseTestEnvironment } from "../../__packages__/cli-test-utils";
import { ITestEnvironment } from "./ITestEnvironment";
import { deleteLocalFile, deleteFiles, deleteJob, deleteJobCommon, deleteDataset } from "../TestUtils";
import { SshSession } from "../../../packages/zosuss/src/SshSession";
import { deleteLocalFile, deleteFiles, deleteJob, deleteJobCommon, deleteDataset } from "../TestUtils";

/**
* Use the utility methods here to setup the test environment for running APIs
Expand Down Expand Up @@ -69,8 +69,40 @@ export class TestEnvironment extends BaseTestEnvironment {
* @memberof TestEnvironment
*/
public static async cleanUp(testEnvironment: ITestEnvironment<ITestPropertiesSchema>) {
// Invoke the superclass's cleanup method
// Delete profiles and plugindir
await super.cleanUp(testEnvironment);

// Deleting resources (if they exist)
if (testEnvironment?.resources?.session) {
const session = testEnvironment.resources.session;
for (const file of testEnvironment.resources.localFiles) {
deleteLocalFile(file);
}
for (const file of testEnvironment.resources.files) {
deleteFiles(session, file);
}
for (const job of testEnvironment.resources.jobs) {
deleteJob(session, job);
}
for (const jobData of testEnvironment.resources.jobData) {
if (jobData.jobname && jobData.jobid) {
deleteJobCommon(session, jobData);
} else {
Imperative.console.info('Error: Missing jobname or jobid for jobData:', jobData);
}
}
for (const dataset of testEnvironment.resources.datasets) {
deleteDataset(session, dataset);
}
testEnvironment.resources = {
localFiles: [],
files: [],
jobs: [],
jobData: [],
datasets: [],
session: testEnvironment.resources.session
};
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { Session } from "@zowe/imperative";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, wait, waitTime, runCliScript } from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { CreateWorkflow, DeleteWorkflow } from "@zowe/zos-workflows-for-zowe-sdk";
import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk";
import { join } from "path";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import * as path from "path";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete, Create, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk";
import { join } from "path";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
let TEST_ENVIRONMENT: ITestEnvironment<ITestPropertiesSchema>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { Session } from "@zowe/imperative";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete, Create, ICreateDataSetOptions, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk";
import { join } from "path";
import { runCliScript } from "@zowe/cli-test-utils";
import { getRandomBytes } from "../../../../../../../__tests__/__src__/TestUtils";

let REAL_SESSION: Session;
let TEST_ENVIRONMENT: ITestEnvironment<ITestPropertiesSchema>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { stripNewLines, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { stripNewLines, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete, IDeleteVsamOptions } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { Delete } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";
import { join } from "path";
import { Session, Imperative } from "@zowe/imperative";
import { inspect } from "util";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { inspect } from "util";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { inspect } from "util";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, stripNewLines, runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName, stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { Session } from "@zowe/imperative";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, stripNewLines, runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName, stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils";
import { runCliScript } from "@zowe/cli-test-utils";


const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import * as path from "path";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { Create, CreateDataSetTypeEnum, Delete, Upload } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import * as path from "path";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName, runCliScript} from "../../../../../../../__tests__/__src__/TestUtils";
import { getRandomBytes, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { Create, CreateDataSetTypeEnum, Delete, Upload } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
Expand Down
Loading

0 comments on commit 2d1c9be

Please sign in to comment.