Skip to content

Commit

Permalink
test: improve assert messages in stream test
Browse files Browse the repository at this point in the history
In test-stream-pipe-await-train-manual-resume, include unexpected value
in error messages.

PR-URL: #16884
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
katie-roberts authored and evanlucas committed Nov 13, 2017
1 parent 271c89e commit 172652b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/parallel/test-stream-pipe-await-drain-manual-resume.js
Expand Up @@ -30,11 +30,13 @@ readable.once('pause', common.mustCall(() => {
assert.strictEqual(
readable._readableState.awaitDrain,
1,
'awaitDrain doesn\'t increase'
'Expected awaitDrain to equal 1 but instead got ' +
`${readable._readableState.awaitDrain}`
);
// First pause, resume manually. The next write() to writable will still
// return false, because chunks are still being buffered, so it will increase
// the awaitDrain counter again.

process.nextTick(common.mustCall(() => {
readable.resume();
}));
Expand All @@ -43,7 +45,8 @@ readable.once('pause', common.mustCall(() => {
assert.strictEqual(
readable._readableState.awaitDrain,
1,
'.resume() does not reset counter'
'.resume() should not reset the counter but instead got ' +
`${readable._readableState.awaitDrain}`
);
// Second pause, handle all chunks from now on. Once all callbacks that
// are currently queued up are handled, the awaitDrain drain counter should
Expand All @@ -64,7 +67,8 @@ writable.on('finish', common.mustCall(() => {
assert.strictEqual(
readable._readableState.awaitDrain,
0,
'awaitDrain not 0 after all chunks are written'
'awaitDrain should equal 0 after all chunks are written but instead got' +
`${readable._readableState.awaitDrain}`
);
// Everything okay, all chunks were written.
}));

0 comments on commit 172652b

Please sign in to comment.