Skip to content

Commit

Permalink
adding tag checks for all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-e-lopez committed Mar 20, 2024
1 parent 17308b6 commit 9367431
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions controller/pages/api/util/testmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export async function validateYamlfile (
additionalFileNames: string[],
bypassParser: boolean | undefined,
authPermissions: AuthPermissions,
validateLegacyOnly?: boolean
validateLegacyOnly?: boolean | undefined
): Promise<ErrorResponse | ValidateYamlfileResult> {
let testRunTimeMn: number | undefined;
let bucketSizeMs: number | undefined;
Expand All @@ -479,7 +479,7 @@ export async function validateYamlfile (
dummyEnvironmentVariables[splunkPath] = dummySplunkPath;
}
// Pass pewpew version legacy/scripting
yamlParser = await YamlParser.parseYamlFile(yamlFile.filepath, dummyEnvironmentVariables, validateLegacyOnly);
yamlParser = await YamlParser.parseYamlFile(yamlFile.filepath, dummyEnvironmentVariables, await validateLegacyOnly);

Check warning on line 482 in controller/pages/api/util/testmanager.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Unexpected `await` of a non-Promise (non-"Thenable") value

Check warning on line 482 in controller/pages/api/util/testmanager.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Unexpected `await` of a non-Promise (non-"Thenable") value
} catch (error) {
return { json: { message: `yamlFile: ${yamlFile.originalFilename || yamlFile.filepath} failed to parse`, error: formatError(error) }, status: 400 };
}
Expand Down
48 changes: 37 additions & 11 deletions controller/test/testmanager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ 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";

Check warning on line 42 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

'latestPewPewVersion' is defined but never used

Check warning on line 42 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

'latestPewPewVersion' is defined but never used
import { mockGetObjectTagging } from "./mock";
import { mockGetObjectTagging, mockS3, mockUploadObject, resetMockS3 } from "./mock";

Check warning on line 43 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Expected 'multiple' syntax before 'single' syntax

Check warning on line 43 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Expected 'multiple' syntax before 'single' syntax
import path from "path";

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

const validateLegacyOnlySuite: Mocha.Suite = describe("getValidateLegacyOnly", () => {
before (() => {
mockS3();
mockUploadObject();
mockGetObjectTagging(new Map([["tagName", "tagValue"]]));
const validateLegacyOnlyArray: [string, boolean][] = [
["0.4.0", true],
Expand All @@ -345,36 +347,60 @@ describe("TestManager", () => {
throw error;
}
}));
// Tags

Check warning on line 350 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Trailing spaces not allowed

Check warning on line 350 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Trailing spaces not allowed
validateLegacyOnlySuite.addTest(new MochaTest(version + " should return tags for that version", async () => {
try {
mockGetObjectTagging(new Map([[VERSION_TAG_NAME, version]]));
await getValidateLegacyOnly(version).then((result: boolean | undefined) => {
log("getValidateLegacyOnly()", LogLevel.INFO, result);
expect(result).to.equal(expected)

Check warning on line 356 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Missing semicolon

Check warning on line 356 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Missing semicolon
});
} catch (error) {
throw error;

Check warning on line 359 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Trailing spaces not allowed

Check warning on line 359 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Trailing spaces not allowed
}
}))

Check warning on line 361 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Missing semicolon

Check warning on line 361 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Missing semicolon
}
});

after(() => {
resetMockS3();
});

Check warning on line 367 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Trailing spaces not allowed

Check warning on line 367 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Trailing spaces not allowed

it("should return undefined for undefined", async () => {
try {
await getValidateLegacyOnly(latestPewPewVersion).then((result: boolean | undefined) => {
expect(result).to.equal(undefined);
});
const expected = "";
mockGetObjectTagging(new Map([[VERSION_TAG_NAME, expected]]));
await getValidateLegacyOnly(undefined).then((result: boolean | undefined) => {
log("getValidateLegacyOnly()", LogLevel.INFO, result);
expect(result).to.equal(undefined)

Check warning on line 375 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Missing semicolon

Check warning on line 375 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Missing semicolon
})

Check warning on line 376 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (18.x)

Missing semicolon

Check warning on line 376 in controller/test/testmanager.spec.ts

View workflow job for this annotation

GitHub Actions / Build project (20.x)

Missing semicolon
} catch (error) {
throw error;
}
});

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

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

} catch (error) {
throw error;
}
Expand Down

0 comments on commit 9367431

Please sign in to comment.