Skip to content

Commit

Permalink
fixing unit test errors
Browse files Browse the repository at this point in the history
Signed-off-by: Amber Torrise <[email protected]>
  • Loading branch information
Amber Torrise committed Jan 22, 2024
1 parent 06079ec commit 9f8a010
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
VALID_COMMANDS_WITH_PROFILES,
SAMPLE_BASE_PROFILE
} from "./__resources__/CommandDefinitions";
import { ImperativeError } from "../../error/src/ImperativeError";
import { ImperativeError } from "../../../src/error/ImperativeError";

// UnitTestUtils.replaceIt();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { CommandProcessor } from "../../../src/cmd/CommandProcessor";
import { ICommandResponse } from "../../../src/cmd/doc/response/response/ICommandResponse";
import { CommandResponse } from "../../../src/cmd/response/CommandResponse";
import { IHelpGenerator } from "../../../src/cmd/help/doc/IHelpGenerator";
import { BasicProfileManager, IProfileManagerFactory, IProfileTypeConfiguration } from "../../profiles";
import { BasicProfileManager, IProfileManagerFactory, IProfileTypeConfiguration } from "../../../src/profiles";
import { ImperativeError } from "../../../src/error";
import { ICommandValidatorResponse } from "../../../src/cmd/doc/response/response/ICommandValidatorResponse";
import { SharedOptions } from "../../../src/cmd/utils/SharedOptions";
Expand All @@ -29,7 +29,7 @@ import { join } from "path";

jest.mock("../../../src/cmd/syntax/SyntaxValidator");
jest.mock("../../../src/cmd/utils/SharedOptions");
jest.mock("../../utilities/ImperativeConfig");
jest.mock("../../../src/utilities/ImperativeConfig");

// Persist the original definitions of process.write
const ORIGINAL_STDOUT_WRITE = process.stdout.write;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*
*/

jest.mock("../../../imperative/src/Imperative");
jest.mock("../../../utilities/ImperativeConfig");
jest.mock("../../../../src/imperative/Imperative");
jest.mock("../../../../src/utilities/ImperativeConfig");

import { IHelpGeneratorFactoryParms } from "../../../../src/cmd/help/doc/IHelpGeneratorFactoryParms";
import { ICommandDefinition } from "../../../../src/cmd/doc/ICommandDefinition";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { CredentialManagerFactory, DefaultCredentialManager } from "../../../../
import { BasicProfileManager } from "../../../../src/profiles/BasicProfileManager";
import { ProfilesConstants, ISaveProfile, IProfileSaved } from "../../../../src/profiles";

jest.mock("../../../profiles/src/utils/ProfileIO");
jest.mock("../../../security/src/DefaultCredentialManager");
jest.mock("../../../../src/profiles/utils/ProfileIO");
jest.mock("../../../../src/profiles/security/DefaultCredentialManager");

// TODO: Some of these tests are not completely isolated, some may cause others to fail depending on mocks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { STRAWBERRY_PROFILE_TYPE } from "../../../../__tests__/__unit__/profiles
import { TEST_PROFILE_ROOT_DIR } from "../../../../__tests__/__unit__/profiles/TestConstants";
import { IProfileLoaded } from "../../../..";

jest.mock("../../../profiles/utils/ProfileIO");
jest.mock("../../../security/DefaultCredentialManager");
jest.mock("../../../../src/profiles/utils/ProfileIO");
jest.mock("../../../../src/security/DefaultCredentialManager");

describe("Cli Profile Manager", () => {
let writtenProfile: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*
*/

jest.mock("../../../profiles/src/BasicProfileManager");
jest.mock("../../../profiles/src/BasicProfileManagerFactory");
jest.mock("../../../utilities/ImperativeConfig");
jest.mock("../../../logger/src/LoggerUtils");
jest.mock("../../../../src/profiles/BasicProfileManager");
jest.mock("../../../../src/profiles/BasicProfileManagerFactory");
jest.mock("../../../../src/utilities/ImperativeConfig");
jest.mock("../../../../src/logger/LoggerUtils");
import { CommandProfileLoader } from "../../../../src/cmd/profiles/CommandProfileLoader";
import { ICommandDefinition } from "../../../../src/cmd/doc/ICommandDefinition";
import { BasicProfileManager } from "../../../../src/profiles/BasicProfileManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

jest.mock("../../logger/src/LoggerUtils");
jest.mock("../../../src/logger/LoggerUtils");
import { AbstractAuthHandler } from "../../../src/imperative";
import { SessConstants } from "../../../src/rest";
import { ImperativeConfig } from "../../../src/utilities/ImperativeConfig";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("Imperative", () => {
// If we error here, jest silently fails and says the test is empty. So let's make sure
// that doesn't happen!

const { Logger } = (jest as any).requireActual("../../logger/src/Logger");
const { Logger } = (jest as any).requireActual("../src/logger/Logger");

Logger.getConsoleLogger().fatal("Imperative.test.ts test execution error!");
Logger.getConsoleLogger().fatal(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import * as npmInterface from "../../../../../../src/imperative/plugins/utilitie
import { PluginIssues } from "../../../../../../src/imperative/plugins/utilities/PluginIssues";
import ConvertProfilesHandler from "../../../../../../src/imperative/config/cmd/convert-profiles/convert-profiles.handler";

jest.mock("../../../../src/plugins/utilities/npm-interface");
jest.mock("../../../../../../src/imperative/src/OverridesLoader");
jest.mock("../../../../../../src/plugins/utilities/npm-interface");
jest.mock("../../../../../../src/imperative/OverridesLoader");

let stdout: string;
let stderr: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import Mock = jest.MockedFunction;

jest.mock("fs");
jest.mock("jsonfile");
jest.mock("../../src/plugins/utilities/PMFConstants");
jest.mock("../../src/plugins/PluginRequireProvider");
jest.mock("../../../../src/imperative/plugins/utilities/PMFConstants");
jest.mock("../../../../src/imperative/plugins/PluginRequireProvider");

import * as fs from "fs";
import { AppSettings } from "../../../../src/settings";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { getMockWrapper } from "../../../../__tests__/__src__/types/MockWrapper";

jest.mock("../../../../../src/utilities/ImperativeConfig");
jest.mock("../../../../src/utilities/ImperativeConfig");
jest.mock("find-up");
jest.mock("path");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ let returnedVal: any;
jest.mock("cross-spawn");
jest.mock("jsonfile");
jest.mock("find-up");
jest.mock("../../../../src/plugins/utilities/PMFConstants");
jest.mock("../../../../src/plugins/PluginManagementFacility");
jest.mock("../../../../src/ConfigurationLoader");
jest.mock("../../../../src/UpdateImpConfig");
jest.mock("../../../../../config/src/ConfigSchema");
jest.mock("../../../../../logger");
jest.mock("../../../../../cmd/src/response/CommandResponse");
jest.mock("../../../../../cmd/src/response/HandlerResponse");
jest.mock("../../../../src/plugins/utilities/NpmFunctions");
jest.mock("../../../../../../src/plugins/utilities/PMFConstants");
jest.mock("../../../../../../src/plugins/PluginManagementFacility");
jest.mock("../../../../../../src/ConfigurationLoader");
jest.mock("../../../../../../src/UpdateImpConfig");
jest.mock("../../../../../../src/config/ConfigSchema");
jest.mock("../../../../../../src/logger");
jest.mock("../../../../../../src/cmd/response/CommandResponse");
jest.mock("../../../../../../src/cmd/response/HandlerResponse");
jest.mock("../../../../../../src/plugins/utilities/NpmFunctions");
jest.doMock("path", () => {
const originalPath = jest.requireActual("path");
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
STRAWBERRY_WITH_REQUIRED_APPLE_DEPENDENCY,
TEST_PROFILE_ROOT_DIR
} from "./TestConstants";
import { BasicProfileManager } from "../src/BasicProfileManager";
import { BasicProfileManager } from "../../../src/profiles/BasicProfileManager";

const BAD_SAMPLE_SAVE_PARMS: ISaveProfile = {
name: "bad_apple",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*
*/

jest.mock("../../../logger/src/LoggerUtils");
jest.mock("../../../../src/LoggerUtils");

import { ConnectionPropsForSessCfg } from "../../../../src/rest/session/ConnectionPropsForSessCfg";
import { CliUtils } from "../../../../src/utilities/CliUtils";
import { ImperativeError } from "../../../../src/error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/* eslint-disable jest/expect-expect */
import { TextUtils } from "../../../utilities/TextUtils";

jest.mock("../../../../imperative/src/Imperative");
jest.mock("../../../../src/imperative/Imperative");
import { inspect, isNullOrUndefined } from "util";
import { TestLogger } from "../../../../__tests__/src/TestLogger";
import { CommandResponse, ICommandDefinition, ICommandValidatorResponse } from "../../../";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/

import { BaseAuthHandler } from "../../handlers/BaseAuthHandler";
import { ICommandArguments } from "../../../../../cmd";
import { ISession, AbstractSession, SessConstants } from "../../../../../rest";
import { ICommandArguments } from "../../../../cmd";
import { ISession, AbstractSession, SessConstants } from "../../../../rest";

export default class FakeAuthHandler extends BaseAuthHandler {
public mProfileType: string = "fruit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import Mock = jest.Mock;

jest.mock("fs");
jest.mock("../../../../io/src/IO");
jest.mock("../../../io/IO");
jest.mock("js-yaml");
jest.mock("yamljs");
jest.mock("../../../../utilities/ImperativeConfig");
jest.mock("../../../utilities/ImperativeConfig");

import * as fs from "fs";
import { IO } from "../../../io/IO";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { IProfileValidationTaskResult } from "../doc/IProfileValidationTaskResul
import { ProfileValidator } from "../api/ProfileValidator";
import { IProfileValidationTask } from "../../..";

jest.mock("../../../../imperative/src/Imperative");
jest.mock("../../../imperative/Imperative");


const oldForceColorOption = process.env.FORCE_COLOR;
Expand Down

0 comments on commit 9f8a010

Please sign in to comment.