fix: write test for setSafeDirectory

This commit is contained in:
Tom Hu 2024-02-23 17:58:33 -08:00
parent eb61afa559
commit e9d7aea5fc
No known key found for this signature in database
GPG key ID: 79155678363963D2

View file

@ -1,10 +1,13 @@
import * as exec from '@actions/exec';
import { import {
PLATFORMS,
getBaseUrl, getBaseUrl,
getCommand,
getPlatform, getPlatform,
isValidPlatform, isValidPlatform,
isWindows, isWindows,
PLATFORMS, setSafeDirectory,
getCommand,
} from './helpers'; } from './helpers';
let OLDOS = process.env.RUNNER_OS; let OLDOS = process.env.RUNNER_OS;
@ -78,3 +81,16 @@ test('getCommand', () => {
expect(getCommand('path', ['-v', '-x'], 'do-upload')) expect(getCommand('path', ['-v', '-x'], 'do-upload'))
.toEqual(['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');
});