Skip to content

Commit

Permalink
Fix ava config
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jul 21, 2021
1 parent e7e664c commit ad03f71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
6 changes: 5 additions & 1 deletion ava.config.js
@@ -1,5 +1,9 @@
export default {
files: ['test/*.js'],
require: ['./test/util/setup.js'],
verbose: true
verbose: true,
environmentVariables: {
GITHUB_TOKEN: '1',
GITLAB_TOKEN: '1'
}
};
6 changes: 4 additions & 2 deletions test/github.js
Expand Up @@ -248,6 +248,8 @@ test('should throw for non-collaborator', async t => {
});

test.serial('should skip authentication and collaborator checks when running on GitHub Actions', async t => {
const GITHUB_ACTIONS = process.env.GITHUB_ACTIONS;
const GITHUB_ACTOR = process.env.GITHUB_ACTOR;
process.env.GITHUB_ACTIONS = 1;
process.env.GITHUB_ACTOR = 'release-it';

Expand All @@ -264,8 +266,8 @@ test.serial('should skip authentication and collaborator checks when running on

authStub.restore();
collaboratorStub.restore();
delete process.env.GITHUB_ACTIONS;
delete process.env.GITHUB_ACTOR;
process.env.GITHUB_ACTIONS = GITHUB_ACTIONS;
process.env.GITHUB_ACTOR = GITHUB_ACTOR;
});

test('should handle octokit client error (without retries)', async t => {
Expand Down
12 changes: 0 additions & 12 deletions test/util/setup.js
@@ -1,17 +1,5 @@
import shelljs from 'shelljs';
import nock from 'nock';
import test from 'ava';

shelljs.config.silent = true;
nock.disableNetConnect();

const { GITHUB_TOKEN, GITLAB_TOKEN, GITHUB_ACTIONS, GITHUB_ACTOR } = process.env;

process.env.GITHUB_TOKEN = process.env.GITLAB_TOKEN = 1;

test.after.always(() => {
process.env.GITHUB_TOKEN = GITHUB_TOKEN;
process.env.GITLAB_TOKEN = GITLAB_TOKEN;
process.env.GITHUB_ACTIONS = GITHUB_ACTIONS;
process.env.GITHUB_ACTOR = GITHUB_ACTOR;
});

0 comments on commit ad03f71

Please sign in to comment.