diff --git a/src/helpers.test.ts b/src/helpers.test.ts index ca5bea4..5ca3a67 100644 --- a/src/helpers.test.ts +++ b/src/helpers.test.ts @@ -1,10 +1,13 @@ +import * as exec from '@actions/exec'; + import { + PLATFORMS, getBaseUrl, + getCommand, getPlatform, isValidPlatform, isWindows, - PLATFORMS, - getCommand, + setSafeDirectory, } from './helpers'; let OLDOS = process.env.RUNNER_OS; @@ -78,3 +81,16 @@ test('getCommand', () => { expect(getCommand('path', ['-v', '-x'], 'do-upload')) .toEqual(['path', '-v', '-x', 'do-upload']); }); + +test('setSafeDirectory', async () => { + process.env.GITHUB_WORKSPACE = 'testOrg/testRepo'; + await setSafeDirectory(); + const testSafeDirectory = ([ + 'git', + 'config', + '--get', + 'safe.directory', + ]).join(' '); + const safeDirectory = await exec.getExecOutput(testSafeDirectory); + expect(safeDirectory.stdout).toBe('testOrg/testRepo\n'); +});