Skip to content

Commit

Permalink
Add a test that an Octokit request is made for remote config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Partington committed Jun 25, 2020
1 parent 32c9898 commit 388403b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
24 changes: 24 additions & 0 deletions lib/config-utils.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,35 @@ test("Remote and local configuration paths correctly identified", t => {
t.assert(configUtils.isLocal('file'));
});

test("Octokit used when reading remote config", async t => {
return await util.withTmpDir(async tmpDir => {
process.env['RUNNER_TEMP'] = tmpDir;
process.env['GITHUB_WORKSPACE'] = tmpDir;

const inputFileContents = `
name: my config
disable-default-queries: true
queries:
- uses: ./
paths-ignore:
- a
- b
paths:
- c/d`;

let ok = new octokit.Octokit({
userAgent: "CodeQL Action",
});
const spyRequest = sinon.stub(ok, "request").resolves(inputFileContents);

sinon.stub(octokit, "Octokit").resolves(ok);

setInput('config-file', 'octo-org/codeql-config/config.yaml@main');
await configUtils.loadConfig();
t.assert(spyRequest.called);
});
});

function doInvalidInputTest(
testName: string,
inputFileContents: string,
Expand Down

0 comments on commit 388403b

Please sign in to comment.