Skip to content

Commit 9f8ddbd

Browse files
committed
Fix GHAE CodeQL setup test
1 parent 9203e31 commit 9f8ddbd

6 files changed

Lines changed: 41 additions & 10 deletions

File tree

lib/codeql.test.js

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

lib/codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/testing-utils.js

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

lib/testing-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ setupTests(test);
2727
const sampleApiDetails = {
2828
auth: "token",
2929
url: "https://github.com",
30-
apiURL: undefined,
31-
registriesAuthTokens: undefined,
30+
apiURL: "https://github.com/__api",
3231
};
3332

3433
const sampleGHAEApiDetails = {
3534
auth: "token",
3635
url: "https://example.githubenterprise.com",
37-
apiURL: undefined,
38-
registriesAuthTokens: undefined,
36+
apiURL: "https://example.githubenterprise.com/api/v3",
3937
};
4038

4139
let stubConfig: Config;
@@ -362,6 +360,21 @@ test("download codeql bundle from github ae endpoint", async (t) => {
362360
path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)
363361
);
364362

363+
sinon
364+
.stub(actionsUtil, "getRequiredInput")
365+
.withArgs("token")
366+
.returns(sampleGHAEApiDetails.auth);
367+
const requiredEnvParamStub = sinon.stub(util, "getRequiredEnvParam");
368+
requiredEnvParamStub
369+
.withArgs("GITHUB_SERVER_URL")
370+
.returns(sampleGHAEApiDetails.url);
371+
requiredEnvParamStub
372+
.withArgs("GITHUB_API_URL")
373+
.returns(sampleGHAEApiDetails.apiURL);
374+
375+
sinon.stub(actionsUtil, "isRunningLocalAction").returns(false);
376+
process.env["GITHUB_ACTION_REPOSITORY"] = "github/codeql-action";
377+
365378
await codeql.setupCodeQL(
366379
undefined,
367380
sampleGHAEApiDetails,

src/testing-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as github from "@actions/github";
22
import { TestFn } from "ava";
3+
import * as nock from "nock";
34
import * as sinon from "sinon";
45

56
import * as apiClient from "./api-client";
@@ -90,6 +91,9 @@ export function setupTests(test: TestFn<any>) {
9091
process.stdout.write(t.context.testOutput);
9192
}
9293

94+
// Undo any modifications made by nock
95+
nock.cleanAll();
96+
9397
// Undo any modifications made by sinon
9498
sinon.restore();
9599

0 commit comments

Comments
 (0)