-
Notifications
You must be signed in to change notification settings - Fork 552
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 #1731 from snyk/fix/jest-config-not-provided
fix: iac unit tests to run as part of CI
- Loading branch information
Showing
19 changed files
with
165 additions
and
131 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
Validating CODEOWNERS rules …
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
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
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
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 was deleted.
Oops, something went wrong.
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
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
2 changes: 1 addition & 1 deletion
2
test/iac-unit-tests/file-parser.spec.ts → ...t/unit/iac-unit-tests/file-parser.spec.ts
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
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,35 @@ | ||
import { extractBundle } from '../../../../src/cli/commands/test/iac-local-execution/file-utils'; | ||
import * as tar from 'tar'; | ||
import { PassThrough } from 'stream'; | ||
|
||
describe('extractBundle', () => { | ||
jest.mock('fs'); | ||
|
||
it('fails to write the file on disk', async () => { | ||
const mockReadable = new PassThrough(); | ||
const mockError = new Error('A stream error'); | ||
|
||
const actualPromise = extractBundle(mockReadable); | ||
mockReadable.emit('error', mockError); | ||
|
||
await expect(actualPromise).rejects.toThrow(mockError); | ||
}); | ||
|
||
it('resolves data successfully', async () => { | ||
const tarSpy = jest.spyOn(tar, 'x'); | ||
|
||
let receivedBundleData = ''; | ||
const mockUntarStream = new PassThrough(); | ||
mockUntarStream.on('data', (evt) => (receivedBundleData += evt.toString())); | ||
tarSpy.mockReturnValueOnce(mockUntarStream); | ||
|
||
const mockBundleStream = new PassThrough(); | ||
const extractBundlePromise = extractBundle(mockBundleStream); | ||
mockBundleStream.write('zipped data'); | ||
mockBundleStream.end(); | ||
|
||
await expect(extractBundlePromise).resolves.toEqual(undefined); | ||
expect(tarSpy).toBeCalledWith({ C: expect.stringMatching('.iac-data') }); | ||
expect(receivedBundleData).toEqual('zipped data'); | ||
}); | ||
}); |
Oops, something went wrong.