From 11d5a53a98ac071c6eff9fe25ed0a47ca34cf914 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Tue, 21 May 2019 12:14:15 -0400 Subject: [PATCH] Remove environment variables after we set them --- packages/core/__tests__/lib.test.ts | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index 80d135f6..e43c9e15 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -1,20 +1,28 @@ import * as os from 'os' import * as core from '../src/core' +const testEnvVars = { + 'my var': '', + 'special char var \r\n];': '', + 'my var2': '', + 'my secret': '', + 'special char secret \r\n];': '', + 'my secret2': '', + + // Set inputs + INPUT_MY_INPUT: 'val', + INPUT_MISSING: '', + 'INPUT_SPECIAL_CHARS_\'\t"\\': '\'\t"\\ repsonse ' +} + describe('@actions/core', () => { beforeEach(() => { - // Clear variables - process.env['my var'] = '' - process.env['special char var \r\n];'] = '' - process.env['my var2'] = '' - process.env['my secret'] = '' - process.env['special char secret \r\n];'] = '' - process.env['my secret2'] = '' + for (const key in testEnvVars) + process.env[key] = testEnvVars[key as keyof typeof testEnvVars] + }) - // Set inputs - process.env['INPUT_MY_INPUT'] = 'val' - process.env['INPUT_MISSING'] = '' - process.env['INPUT_SPECIAL_CHARS_\'\t"\\'] = '\'\t"\\ repsonse ' + afterEach(() => { + for (const key in testEnvVars) Reflect.deleteProperty(testEnvVars, key) }) it('exportVariable produces the correct command and sets the env', () => {