Skip to content

Commit

Permalink
updating more of the files
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-e-lopez committed Mar 19, 2024
1 parent e4b51af commit 17308b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions controller/pages/api/util/testmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export async function downloadPriorTestId (
};
}

// / Export for testing
// Export for testing
export async function getValidateLegacyOnly (version: string | undefined): Promise<boolean | undefined> {
// undefined or "latest" parse as anything (reutrn undefined)
if (!version || version === latestPewPewVersion) {
Expand Down Expand Up @@ -1221,8 +1221,8 @@ export abstract class TestManager {
log("environmentVariables", LogLevel.TRACE, environmentVariablesFile);

// Pass pewpew version legacy/scripting
const validateLegacyOnly = getValidateLegacyOnly(version);
const validateResult: ErrorResponse | ValidateYamlfileResult = await validateYamlfile(yamlFile, PpaasEncryptEnvironmentFile.getEnvironmentVariables(environmentVariablesFile), additionalFileNames, bypassParser, authPermissions, await validateLegacyOnly);
const validateLegacyOnly = await getValidateLegacyOnly(version);
const validateResult: ErrorResponse | ValidateYamlfileResult = await validateYamlfile(yamlFile, PpaasEncryptEnvironmentFile.getEnvironmentVariables(environmentVariablesFile), additionalFileNames, bypassParser, authPermissions, validateLegacyOnly);
// eslint-disable-next-line no-prototype-builtins
if (validateResult.hasOwnProperty("json")) {
return validateResult as ErrorResponse;
Expand Down
19 changes: 15 additions & 4 deletions controller/test/testmanager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ import type { File, FileJSON } from "formidable";
import { Test as MochaTest } from "mocha";
import { PpaasEncryptS3File } from "../pages/api/util/ppaasencrypts3file";
import { TestSchedulerIntegration } from "./testscheduler.spec";
import { VERSION_TAG_NAME } from "../pages/api/util/pewpew";
import { expect } from "chai";
import { latestPewPewVersion } from "../pages/api/util/clientutil";
import { mockGetObjectTagging } from "./mock";
import path from "path";

logger.config.LogFileName = "ppaas-controller";
Expand Down Expand Up @@ -318,6 +320,7 @@ describe("TestManager", () => {

const validateLegacyOnlySuite: Mocha.Suite = describe("getValidateLegacyOnly", () => {
before (() => {
mockGetObjectTagging(new Map([["tagName", "tagValue"]]));
const validateLegacyOnlyArray: [string, boolean][] = [
["0.4.0", true],
["0.5.0", true],
Expand Down Expand Up @@ -347,23 +350,31 @@ describe("TestManager", () => {

it("should return undefined for undefined", async () => {
try {
expect(await getValidateLegacyOnly(undefined)).to.equal(false);
await getValidateLegacyOnly(latestPewPewVersion).then((result: boolean | undefined) => {
expect(result).to.equal(undefined);
});
} catch (error) {
throw error;
}
});

it("should return undefined for empty string", async () => {
try {
expect(await getValidateLegacyOnly("")).to.equal(false);
mockGetObjectTagging(new Map([[VERSION_TAG_NAME, ""]]));
await getValidateLegacyOnly(latestPewPewVersion).then((result: boolean | undefined) => {
expect(result).to.equal(undefined);
});
} catch (error) {
throw error;
}
});

it("should return undefined for latest", async () => {
try {
expect(await getValidateLegacyOnly(latestPewPewVersion)).to.equal(false);
const expected = "latest";
mockGetObjectTagging(new Map([[VERSION_TAG_NAME, expected]]));
await getValidateLegacyOnly(latestPewPewVersion).then((result: boolean | undefined) => {
expect(result).to.equal(expected);
});
} catch (error) {
throw error;
}
Expand Down

0 comments on commit 17308b6

Please sign in to comment.