-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1088 from Green-Software-Foundation/code-ql
Provide codeql fixes
- Loading branch information
Showing
2 changed files
with
52 additions
and
29 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,22 +11,29 @@ jest.mock('../../../common/util/logger', () => ({ | |
}, | ||
})); | ||
|
||
jest.mock('../../../common/util/helpers', () => { | ||
const originalModule = jest.requireActual('../../../common/util/helpers'); | ||
jest.mock('child_process', () => { | ||
const originalModule = jest.requireActual('child_process'); | ||
return { | ||
...originalModule, | ||
execPromise: async (param: any) => { | ||
execFileSync: (file: any, args: any) => { | ||
switch (process.env.NPM_INSTALL) { | ||
case 'true': | ||
expect(param).toEqual('npm install @grnsft/[email protected]'); | ||
expect(file).toEqual('npm install @grnsft/[email protected]'); | ||
break; | ||
case 'npm init -y': | ||
expect(param).toEqual('npm init -y'); | ||
expect(file).toEqual('npm init -y'); | ||
break; | ||
case 'if-check': | ||
expect(param).toEqual( | ||
"npm run if-env -- -m ./src/__mocks__/mock-manifest.yaml && npm run if-run -- -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest && node -p 'Boolean(process.stdout.isTTY)' | npm run if-diff -- -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml" | ||
); | ||
expect( | ||
[ | ||
'npm run if-env -- -m ./src/__mocks__/mock-manifest.yaml', | ||
'npm run if-run -- -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest', | ||
'node -p Boolean(process.stdout.isTTY)', | ||
'npm run if-diff -- -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml', | ||
].includes( | ||
Array.isArray(args) ? `${file} ${args.join(' ')}` : file.trim() | ||
) | ||
).toBeTruthy(); | ||
break; | ||
case 'if-check-cwd': | ||
expect(param).toEqual( | ||
|
@@ -60,7 +67,7 @@ describe('if-check/util/npm: ', () => { | |
|
||
await executeCommands(manifest, false); | ||
|
||
expect.assertions(2); | ||
expect.assertions(6); | ||
expect(logSpy).toHaveBeenCalledWith( | ||
'✔ if-check successfully verified mock-manifest.yaml\n' | ||
); | ||
|
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