From ad03f715e1e93f9fe4bd79ec34ba925588820def Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Sat, 17 Jul 2021 13:51:52 +0200 Subject: [PATCH] Fix ava config --- ava.config.js | 6 +++++- test/github.js | 6 ++++-- test/util/setup.js | 12 ------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ava.config.js b/ava.config.js index bfb2ac15..4c71b9c2 100644 --- a/ava.config.js +++ b/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' + } }; diff --git a/test/github.js b/test/github.js index 6c4c29db..8177f1fc 100644 --- a/test/github.js +++ b/test/github.js @@ -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'; @@ -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 => { diff --git a/test/util/setup.js b/test/util/setup.js index 5dcf63af..5eed2bb4 100644 --- a/test/util/setup.js +++ b/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; -});