Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a test that Octokit isn't used for local config
Sam Partington committed Jun 24, 2020

Unverified

No user is associated with the committer email.
1 parent b0af569 commit f4cf65c
Showing 3 changed files with 54 additions and 4 deletions.
29 changes: 26 additions & 3 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.

27 changes: 27 additions & 0 deletions src/config-utils.test.ts
@@ -1,6 +1,8 @@
import * as octokit from '@octokit/rest';
import test from 'ava';
import * as fs from 'fs';
import * as path from 'path';
import sinon from 'sinon';

import * as configUtils from './config-utils';
import {silenceDebugOutput} from './testing-utils';
@@ -125,6 +127,31 @@ test("load non-empty input", async t => {
});
});

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

const spyKit = sinon.spy(octokit, "Octokit");

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

fs.writeFileSync(path.join(tmpDir, 'input'), inputFileContents, 'utf8');
setInput('config-file', 'input');
await configUtils.loadConfig();
t.false(spyKit.called);
});
});

function doInvalidInputTest(
testName: string,
inputFileContents: string,

0 comments on commit f4cf65c

Please sign in to comment.