mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-16 08:32:34 +00:00
wrapper: Write stdout/stderr data to stream when received (#410)
* wrapper: write stdout/stderr data to stream when received * add a delay test * temp comment * uncomment actions * add changelog
This commit is contained in:
parent
5f32e8acaf
commit
99441ecd44
7 changed files with 85 additions and 18 deletions
|
|
@ -6,12 +6,31 @@
|
|||
const OutputListener = require('../lib/output-listener');
|
||||
|
||||
describe('output-listener', () => {
|
||||
it('receives and exposes data', () => {
|
||||
it('receives and buffers data to .contents', () => {
|
||||
const listener = new OutputListener();
|
||||
const listen = listener.listener;
|
||||
|
||||
listen(Buffer.from('foo'));
|
||||
listen(Buffer.from('bar'));
|
||||
listen(Buffer.from('baz'));
|
||||
|
||||
expect(listener.contents).toEqual('foobarbaz');
|
||||
});
|
||||
|
||||
it('receives and writes data to stream immediately', () => {
|
||||
const mockWrite = jest.fn();
|
||||
const listener = new OutputListener({ write: mockWrite });
|
||||
const listen = listener.listener;
|
||||
|
||||
listen(Buffer.from('first write'));
|
||||
expect(mockWrite.mock.lastCall[0]).toStrictEqual(Buffer.from('first write'));
|
||||
|
||||
listen(Buffer.from('second write'));
|
||||
expect(mockWrite.mock.lastCall[0]).toStrictEqual(Buffer.from('second write'));
|
||||
|
||||
listen(Buffer.from('third write'));
|
||||
expect(mockWrite.mock.lastCall[0]).toStrictEqual(Buffer.from('third write'));
|
||||
|
||||
expect(mockWrite).toBeCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue