-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve code quality and write tests
- Loading branch information
1 parent
db44db4
commit 43178a7
Showing
3,599 changed files
with
255,504 additions
and
785,580 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Explicitly not ignoring node_modules so that they are included in package downloaded by runner | ||
!node_modules/ | ||
__tests__/runner/* | ||
|
||
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import * as features from '../src/features'; | ||
|
||
let valid_extensions = ['xdebug', 'pcov']; | ||
jest.mock('../src/pecl', () => ({ | ||
checkPECLExtension: jest.fn().mockImplementation(extension => { | ||
return valid_extensions.indexOf(extension) !== -1; | ||
}) | ||
})); | ||
|
||
describe('Features tests', () => { | ||
it('checking addExtensionOnWindows', async () => { | ||
let win32: string = await features.addExtension( | ||
'xdebug, pcov', | ||
'7.2', | ||
'win32' | ||
); | ||
expect(win32).toContain( | ||
'Install-PhpExtension xdebug -MinimumStability stable' | ||
); | ||
expect(win32).toContain( | ||
'Install-PhpExtension pcov -MinimumStability stable' | ||
); | ||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32'); | ||
expect(win32).toContain( | ||
'Install-PhpExtension xdebug -MinimumStability alpha' | ||
); | ||
expect(win32).toContain( | ||
'Install-PhpExtension pcov -MinimumStability alpha' | ||
); | ||
|
||
win32 = await features.addExtension('DoesNotExist', '7.2', 'win32'); | ||
expect(win32).not.toContain( | ||
'Install-PhpExtension DoesNotExist -MinimumStability stable' | ||
); | ||
}); | ||
it('checking addExtensionOnLinux', async () => { | ||
let linux: string = await features.addExtension( | ||
'xdebug, pcov', | ||
'7.2', | ||
'linux' | ||
); | ||
expect(linux).toContain( | ||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-xdebug' | ||
); | ||
expect(linux).toContain( | ||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov' | ||
); | ||
}); | ||
it('checking addExtensionOnDarwin', async () => { | ||
let darwin: string = await features.addExtension( | ||
'xdebug, pcov', | ||
'7.2', | ||
'darwin' | ||
); | ||
expect(darwin).toContain('sudo pecl install xdebug'); | ||
expect(darwin).toContain('sudo pecl install pcov'); | ||
|
||
darwin = await features.addExtension('DoesNotExist', '7.2', 'darwin'); | ||
expect(darwin).not.toContain('sudo pecl install DoesNotExist'); | ||
}); | ||
|
||
it('checking addINIValuesOnWindows', async () => { | ||
let win32: string = await features.addINIValues( | ||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', | ||
'win32' | ||
); | ||
expect(win32).toContain( | ||
'Add-Content C:\\tools\\php$version\\php.ini "post_max_size=256M"' | ||
); | ||
expect(win32).toContain( | ||
'Add-Content C:\\tools\\php$version\\php.ini "short_open_tag=On"' | ||
); | ||
expect(win32).toContain( | ||
'Add-Content C:\\tools\\php$version\\php.ini "date.timezone=Asia/Kolkata"' | ||
); | ||
}); | ||
|
||
it('checking addINIValuesOnLinux', async () => { | ||
let linux: string = await features.addINIValues( | ||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', | ||
'linux' | ||
); | ||
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file'); | ||
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file'); | ||
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file'); | ||
}); | ||
|
||
it('checking addINIValuesOnDarwin', async () => { | ||
let darwin: string = await features.addINIValues( | ||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', | ||
'darwin' | ||
); | ||
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file'); | ||
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file'); | ||
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as utils from '../src/utils'; | ||
import * as pecl from '../src/pecl'; | ||
|
||
let valid_extensions = ['xdebug', 'pcov']; | ||
jest.mock('../src/pecl', () => ({ | ||
checkPECLExtension: jest.fn().mockImplementation(extension => { | ||
return valid_extensions.indexOf(extension) !== -1; | ||
}) | ||
})); | ||
|
||
async function cleanup(path: string): Promise<void> { | ||
fs.unlink(path, error => { | ||
if (error) { | ||
console.log(error); | ||
} | ||
}); | ||
} | ||
|
||
describe('Utils tests', () => { | ||
it('checking getInput', async () => { | ||
process.env['test'] = 'setup-php'; | ||
expect(await utils.getInput('test', false)).toBe('setup-php'); | ||
expect(await utils.getInput('DoesNotExist', false)).toBe(''); | ||
}); | ||
|
||
it('checking asyncForEach', async () => { | ||
let array: Array<number> = [1, 2, 3, 4]; | ||
let sum: number = 0; | ||
await utils.asyncForEach(array, function(num: number): void { | ||
sum += num; | ||
}); | ||
expect(sum).toBe(10); | ||
}); | ||
|
||
it('checking readScripts', async () => { | ||
let rc: string = fs.readFileSync( | ||
path.join(__dirname, '../src/7.4.sh'), | ||
'utf8' | ||
); | ||
let darwin: string = fs.readFileSync( | ||
path.join(__dirname, '../src/darwin.sh'), | ||
'utf8' | ||
); | ||
let linux: string = fs.readFileSync( | ||
path.join(__dirname, '../src/linux.sh'), | ||
'utf8' | ||
); | ||
let win32: string = fs.readFileSync( | ||
path.join(__dirname, '../src/win32.ps1'), | ||
'utf8' | ||
); | ||
expect(rc).toBe(await utils.readScript('darwin.sh', '7.4', 'darwin')); | ||
expect(darwin).toBe(await utils.readScript('darwin.sh', '7.3', 'darwin')); | ||
expect(linux).toBe(await utils.readScript('linux.sh', '7.3', 'linux')); | ||
expect(win32).toBe(await utils.readScript('win32.ps1', '7.3', 'win32')); | ||
}); | ||
|
||
it('checking writeScripts', async () => { | ||
let testString: string = 'sudo apt-get install php'; | ||
await utils.writeScript('test.sh', '10', testString); | ||
await fs.readFile(path.join(__dirname, '../10test.sh'), function( | ||
error: any, | ||
data: Buffer | ||
) { | ||
expect(testString).toBe(data.toString()); | ||
}); | ||
await cleanup('./10test.sh'); | ||
}); | ||
|
||
it('checking extensionArray', async () => { | ||
expect(await utils.extensionArray('a, b, php_c, php-d')).toEqual([ | ||
'a', | ||
'b', | ||
'c', | ||
'd' | ||
]); | ||
}); | ||
|
||
it('checking INIArray', async () => { | ||
expect(await utils.INIArray('a=1, b=2, c=3')).toEqual([ | ||
'a=1', | ||
'b=2', | ||
'c=3' | ||
]); | ||
}); | ||
|
||
it('checking checkPECLExtension', async () => { | ||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false); | ||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ module.exports = { | |
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
verbose: true | ||
} | ||
verbose: true, | ||
collectCoverage: true | ||
}; |
Oops, something went wrong.