diff options
author | Rich Trott <rtrott@gmail.com> | 2015-12-30 14:02:28 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-01-02 13:43:36 -0800 |
commit | 44ed9998cfd83cfad109af9d00b55edfff7d2bd4 (patch) | |
tree | 344c74dad35794613e70d2402821c044d345c4ea /test/parallel/test-fs-empty-readStream.js | |
parent | 4e155e8e2ef52379860494825fb4dd539799074d (diff) | |
download | android-node-v8-44ed9998cfd83cfad109af9d00b55edfff7d2bd4.tar.gz android-node-v8-44ed9998cfd83cfad109af9d00b55edfff7d2bd4.tar.bz2 android-node-v8-44ed9998cfd83cfad109af9d00b55edfff7d2bd4.zip |
test: refactor test-fs-empty-readStream
Refactor test to remove unnecessary booleans and one unnecesary timer.
Instead, throw Error objects where appropriate and rely on
common.mustCall().
The timer seemed to be the source of an issue when parallelizing tests.
Ref: https://github.com/nodejs/node/pull/4476#issuecomment-168080875
PR-URL: https://github.com/nodejs/node/pull/4490
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-empty-readStream.js')
-rw-r--r-- | test/parallel/test-fs-empty-readStream.js | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/test/parallel/test-fs-empty-readStream.js b/test/parallel/test-fs-empty-readStream.js index 0863e0cdba..c5a016f9ea 100644 --- a/test/parallel/test-fs-empty-readStream.js +++ b/test/parallel/test-fs-empty-readStream.js @@ -15,15 +15,7 @@ fs.open(emptyFile, 'r', function(error, fd) { throw new Error('data event should not emit'); }); - var readEmit = false; - read.once('end', function() { - readEmit = true; - console.error('end event 1'); - }); - - setTimeout(function() { - assert.equal(readEmit, true); - }, common.platformTimeout(50)); + read.once('end', common.mustCall(function endEvent1() {})); }); fs.open(emptyFile, 'r', function(error, fd) { @@ -36,13 +28,11 @@ fs.open(emptyFile, 'r', function(error, fd) { throw new Error('data event should not emit'); }); - var readEmit = false; - read.once('end', function() { - readEmit = true; - console.error('end event 2'); + read.once('end', function endEvent2() { + throw new Error('end event should not emit'); }); setTimeout(function() { - assert.equal(readEmit, false); + assert.equal(read.isPaused(), true); }, common.platformTimeout(50)); }); |