diff --git a/controller/integration/pewpew.spec.ts b/controller/integration/pewpew.spec.ts index 34460888..4b158e7b 100644 --- a/controller/integration/pewpew.spec.ts +++ b/controller/integration/pewpew.spec.ts @@ -183,6 +183,7 @@ describe("PewPew Util Integration", () => { expect(match, "pewpew match").to.not.equal(null); expect(match!.length, "pewpew match.length").to.be.greaterThan(1); const version: string = match![1]; + expect(global.currentLatestVersion, "global.currentLatestVersion").to.equal(version); // If this runs before the other acceptance tests populate the shared pewpew versions if (!sharedPewPewVersions) { sharedPewPewVersions = [latestPewPewVersion]; @@ -271,7 +272,10 @@ describe("PewPew Util Integration", () => { it("getCurrentPewPewLatestVersion", async () => { expect(currentPewPewLatestVersion, "currentPewPewLatestVersion").to.not.equal(undefined); + // We need to reset this to force it to go to S3. Otherwise it just returns the value + global.currentLatestVersion = undefined; const result = await getCurrentPewPewLatestVersion(); + log("getCurrentPewPewLatestVersion: " + result, LogLevel.DEBUG, result); expect(result, "result").to.equal(currentPewPewLatestVersion); }); }); diff --git a/controller/pages/api/util/pewpew.ts b/controller/pages/api/util/pewpew.ts index d7aaca1f..a3b81d00 100644 --- a/controller/pages/api/util/pewpew.ts +++ b/controller/pages/api/util/pewpew.ts @@ -162,7 +162,7 @@ export async function postPewPew (parsedForm: ParsedForm, authPermissions: AuthP // If latest version is being updated: if (latest) { global.currentLatestVersion = version; - log("Sucessfully updated currentLatestVersion. ", LogLevel.INFO, version); + log("Sucessfully updated currentLatestVersion: " + version, LogLevel.INFO, version); } log(PEWPEW_BINARY_EXECUTABLE + " only uploaded, version: " + versionLogDisplay, LogLevel.INFO, { files, authPermissions: getLogAuthPermissions(authPermissions) }); return { json: { message: "PewPew uploaded, version: " + versionLogDisplay }, status: 200 }; @@ -237,13 +237,18 @@ export async function getCurrentPewPewLatestVersion (): Promise { after(() => { resetMockS3(); + // We need to reset this to force it to go to S3 later. Otherwise it just returns the value + global.currentLatestVersion = undefined; }); describe("getCurrentPewPewLatestVersion", () => { it("getCurrentPewPewLatestVersion should return version with latest tag from S3", (done: Mocha.Done) => { const expected = "0.5.13"; mockGetObjectTagging(new Map([[VERSION_TAG_NAME, expected]])); + // We need to reset this to force it to go to S3. Otherwise it just returns the value + global.currentLatestVersion = undefined; getCurrentPewPewLatestVersion().then((result: string | undefined) => { log("getPewPewVersionsInS3()", LogLevel.DEBUG, result); expect(result).to.equal(expected); @@ -186,6 +190,7 @@ describe("PewPew Util", () => { files }; log("postPewPew parsedForm", LogLevel.DEBUG, parsedForm); + global.currentLatestVersion = "0.0.1"; // bogus value postPewPew(parsedForm, authAdmin).then((res: ErrorResponse) => { log("postPewPew res", LogLevel.DEBUG, res); expect(res.status, JSON.stringify(res.json)).to.equal(200); @@ -195,6 +200,12 @@ describe("PewPew Util", () => { expect(body.message).to.not.equal(undefined); expect(body.message).to.include("PewPew uploaded, version"); expect(body.message).to.include("as latest"); + const match: RegExpMatchArray | null = body.message.match(/PewPew uploaded, version: (\d+\.\d+\.\d+)/); + log(`pewpew match: ${match}`, LogLevel.DEBUG, match); + expect(match, "pewpew match").to.not.equal(null); + expect(match!.length, "pewpew match.length").to.be.greaterThan(1); + const version: string = match![1]; + expect(global.currentLatestVersion, "global.currentLatestVersion").to.equal(version); done(); }).catch((error) => { log("postPewPew error", LogLevel.ERROR, error);