mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-23 23:29:07 +07:00
Refactor install.ts
This commit is contained in:
@ -4,7 +4,7 @@ import * as install from '../src/install';
|
||||
* Mock install.ts
|
||||
*/
|
||||
jest.mock('../src/install', () => ({
|
||||
build: jest.fn().mockImplementation(
|
||||
getScript: jest.fn().mockImplementation(
|
||||
async (
|
||||
filename: string,
|
||||
version: string,
|
||||
@ -45,11 +45,19 @@ jest.mock('../src/install', () => ({
|
||||
switch (os_version) {
|
||||
case 'darwin':
|
||||
case 'linux':
|
||||
script = await install.build(os_version + '.sh', version, os_version);
|
||||
script = await install.getScript(
|
||||
os_version + '.sh',
|
||||
version,
|
||||
os_version
|
||||
);
|
||||
script += 'bash script.sh ' + version + ' ' + __dirname;
|
||||
break;
|
||||
case 'win32':
|
||||
script = await install.build(os_version + '.sh', version, os_version);
|
||||
script = await install.getScript(
|
||||
os_version + '.sh',
|
||||
version,
|
||||
os_version
|
||||
);
|
||||
script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
|
||||
break;
|
||||
default:
|
||||
|
@ -209,6 +209,15 @@ describe('Utils tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('checking scriptTool', async () => {
|
||||
expect(await utils.scriptTool('linux')).toBe('bash');
|
||||
expect(await utils.scriptTool('darwin')).toBe('bash');
|
||||
expect(await utils.scriptTool('win32')).toBe('pwsh');
|
||||
expect(await utils.scriptTool('openbsd')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking customPackage', async () => {
|
||||
const script_path: string = path.join('ext', 'pkg.sh');
|
||||
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
|
||||
|
Reference in New Issue
Block a user