Skip to content

Commit bce0deb

Browse files
committed
Fix log message / returned version
1 parent db33d20 commit bce0deb

File tree

3 files changed

+47
-40
lines changed

3 files changed

+47
-40
lines changed

lib/start-proxy-action.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.test.ts

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -622,49 +622,52 @@ test("getProxyBinaryPath - returns path from tool cache if available", async (t)
622622
});
623623

624624
test("getProxyBinaryPath - downloads proxy if not in cache", async (t) => {
625+
const logger = new RecordingLogger();
625626
const downloadUrl = "url-we-want";
626627
mockGetReleaseByTag([
627628
{ name: startProxyExports.getProxyPackage(), url: downloadUrl },
628629
]);
629630

630-
await withRecordingLoggerAsync(async (logger) => {
631-
const toolcachePath = "/path/to/proxy/dir";
632-
const find = sinon.stub(toolcache, "find").returns("");
633-
const getApiDetails = sinon.stub(apiClient, "getApiDetails").returns({
634-
auth: "",
635-
url: "",
636-
apiURL: "",
637-
});
638-
const getAuthorizationHeaderFor = sinon
639-
.stub(apiClient, "getAuthorizationHeaderFor")
640-
.returns(undefined);
641-
const archivePath = "/path/to/archive";
642-
const downloadTool = sinon
643-
.stub(toolcache, "downloadTool")
644-
.resolves(archivePath);
645-
const extractedPath = "/path/to/extracted";
646-
const extractTar = sinon
647-
.stub(toolcache, "extractTar")
648-
.resolves(extractedPath);
649-
const cacheDir = sinon.stub(toolcache, "cacheDir").resolves(toolcachePath);
631+
const toolcachePath = "/path/to/proxy/dir";
632+
const find = sinon.stub(toolcache, "find").returns("");
633+
const getApiDetails = sinon.stub(apiClient, "getApiDetails").returns({
634+
auth: "",
635+
url: "",
636+
apiURL: "",
637+
});
638+
const getAuthorizationHeaderFor = sinon
639+
.stub(apiClient, "getAuthorizationHeaderFor")
640+
.returns(undefined);
641+
const archivePath = "/path/to/archive";
642+
const downloadTool = sinon
643+
.stub(toolcache, "downloadTool")
644+
.resolves(archivePath);
645+
const extractedPath = "/path/to/extracted";
646+
const extractTar = sinon
647+
.stub(toolcache, "extractTar")
648+
.resolves(extractedPath);
649+
const cacheDir = sinon.stub(toolcache, "cacheDir").resolves(toolcachePath);
650+
651+
const path = await startProxyExports.getProxyBinaryPath(
652+
logger,
653+
createFeatures([]),
654+
);
650655

651-
const path = await startProxyExports.getProxyBinaryPath(
652-
logger,
653-
createFeatures([]),
654-
);
656+
t.assert(find.calledOnce);
657+
t.assert(getApiDetails.calledOnce);
658+
t.assert(getAuthorizationHeaderFor.calledOnce);
659+
t.assert(downloadTool.calledOnceWith(downloadUrl));
660+
t.assert(extractTar.calledOnceWith(archivePath));
661+
t.assert(cacheDir.calledOnceWith(extractedPath));
662+
t.assert(path);
663+
t.is(
664+
path,
665+
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
666+
);
655667

656-
t.assert(find.calledOnce);
657-
t.assert(getApiDetails.calledOnce);
658-
t.assert(getAuthorizationHeaderFor.calledOnce);
659-
t.assert(downloadTool.calledOnceWith(downloadUrl));
660-
t.assert(extractTar.calledOnceWith(archivePath));
661-
t.assert(cacheDir.calledOnceWith(extractedPath));
662-
t.assert(path);
663-
t.is(
664-
path,
665-
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
666-
);
667-
});
668+
checkExpectedLogMessages(t, logger.messages, [
669+
`Found '${startProxyExports.getProxyPackage()}' in release '${defaults.bundleVersion}' at '${downloadUrl}'`,
670+
]);
668671
});
669672

670673
test("getProxyBinaryPath - downloads proxy based on features if not in cache", async (t) => {
@@ -745,4 +748,8 @@ test("getProxyBinaryPath - downloads proxy based on features if not in cache", a
745748
filepath.join(toolcachePath, startProxyExports.getProxyFilename()),
746749
);
747750
});
751+
752+
checkExpectedLogMessages(t, logger.messages, [
753+
`Found '${startProxyExports.getProxyPackage()}' in release '${expectedTag}' at '${downloadUrl}'`,
754+
]);
748755
});

src/start-proxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ export async function getDownloadUrl(
452452
for (const asset of cliRelease.data.assets) {
453453
if (asset.name === proxyPackage) {
454454
logger.info(
455-
`Found '${proxyPackage}' in release '${defaults.bundleVersion}' at '${asset.url}'`,
455+
`Found '${proxyPackage}' in release '${versionInfo.tagName}' at '${asset.url}'`,
456456
);
457457
return {
458458
url: asset.url,
459459
// The `update-job-proxy` doesn't have a version as such. Since we now bundle it
460460
// with CodeQL CLI bundle releases, we use the corresponding CLI version to
461461
// differentiate between (potentially) different versions of `update-job-proxy`.
462-
version: defaults.cliVersion,
462+
version: versionInfo.cliVersion,
463463
};
464464
}
465465
}

0 commit comments

Comments
 (0)