Skip to content

Commit

Permalink
destroy streams
Browse files Browse the repository at this point in the history
  • Loading branch information
epicfaace committed Aug 15, 2020
1 parent 1a3f2f4 commit ee55c2a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/test/docker-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ jest.mock('../src/tasks/updateScanTaskStatus', () => ({
}));

let event;
let stream: Readable;
jest.mock('dockerode', () => {
class MockDockerode {
async getEvents() {
return Readable.from([JSON.stringify(event)]);
stream = Readable.from([JSON.stringify(event)]);
return stream;
}
}
return MockDockerode;
});

afterEach(() => {
if (stream) {
stream.destroy();
}
});

test('should listen to a start event', async () => {
event = {
status: 'start',
Expand Down

0 comments on commit ee55c2a

Please sign in to comment.