Filter extensions marked for removal

This commit is contained in:
Shivam Mathur
2020-05-10 13:56:23 +05:30
parent 340bfd72bd
commit 28ef0db7df
7 changed files with 2090 additions and 1043 deletions

View File

@@ -1,4 +1,5 @@
import * as install from '../src/cache';
import * as utils from '../src/utils';
/**
* Mock cache.ts
@@ -6,8 +7,11 @@ import * as install from '../src/cache';
jest.mock('../src/cache', () => ({
run: jest.fn().mockImplementation(
async (): Promise<string> => {
const version: string = process.env['php-version'] || '';
const extensions: string = process.env['extensions'] || '';
let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const extensions = await utils.filterExtensions(
process.env['extensions'] || ''
);
const key: string = process.env['key'] || '';
const script_path = 'extensions.sh';
@@ -22,10 +26,8 @@ jest.mock('../src/cache', () => ({
* Function to set the process.env
*
* @param version
* @param os
* @param extension_csv
* @param ini_values_csv
* @param coverage_driver
* @param extensions
* @param key
*/
function setEnv(
version: string | number,
@@ -51,4 +53,11 @@ describe('Install', () => {
const script: string = await install.run();
expect(script).toContain('bash extensions.sh "xdebug, zip" cache-v2 7.4');
});
it('Test Run', async () => {
setEnv('7.4', 'xdebug, :zip', 'cache-v2');
// @ts-ignore
const script: string = await install.run();
expect(script).toContain('bash extensions.sh "xdebug" cache-v2 7.4');
});
});

View File

@@ -1,5 +1,3 @@
import * as fs from 'fs';
import * as path from 'path';
import * as utils from '../src/utils';
jest.mock('@actions/core', () => ({
@@ -19,4 +17,9 @@ describe('Utils tests', () => {
);
expect(await utils.getInput('DoesNotExist', false)).toBe('');
});
it('checking filterExtensions', async () => {
expect(await utils.filterExtensions('a,:b,c')).toBe('a,c');
expect(await utils.filterExtensions('a, :b, c')).toBe('a, c');
});
});