Skip to content

Commit

Permalink
stream: test createTransformStream with process.stdout
Browse files Browse the repository at this point in the history
The test consist on usage of process.stdout in pipeline
returning an error when done

Refs: nodejs#39447
  • Loading branch information
ktfth committed Jul 31, 2021
1 parent 21f3bf3 commit 4807ec6
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ const net = require('net');
write (chunk, enc, cb) {
cb()
}
})
});

function createTransformStream (tf, context) {
return new Transform({
readableObjectMode: true,
writableObjectMode: true,

transform (chunk, encoding, done) {
tf(chunk, context, done)
tf(chunk, context, done);
}
})
});
}

const ts = createTransformStream((chunk, _, done) => done(new Error('Artificial error')))
const ts = createTransformStream((chunk, _, done) => done(new Error('Artificial error')));

pipeline(ts, w, common.mustCall((err) => {
assert.ok(err, 'should have an error');
Expand All @@ -113,6 +113,27 @@ const net = require('net');
ts.write('test')
}

{
function createTransformStream (tf, context) {
return new Transform({
readableObjectMode: true,
writableObjectMode: true,

transform (chunk, encoding, done) {
tf(chunk, context, done);
}
})
}

const ts = createTransformStream((chunk, _, done) => done(new Error('Artificial error')));

pipeline(ts, process.stdout, common.mustCall((err) => {
assert.ok(err, 'should have an error');
}))

ts.write('test');
}

{
const read = new Readable({
read() {}
Expand Down

0 comments on commit 4807ec6

Please sign in to comment.