Browse Source

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>
v4.x
Rich Trott 9 years ago
committed by Myles Borins
parent
commit
7ca3c6c388
  1. 18
      test/parallel/test-fs-empty-readStream.js

18
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'); throw new Error('data event should not emit');
}); });
var readEmit = false; read.once('end', common.mustCall(function endEvent1() {}));
read.once('end', function() {
readEmit = true;
console.error('end event 1');
});
setTimeout(function() {
assert.equal(readEmit, true);
}, common.platformTimeout(50));
}); });
fs.open(emptyFile, 'r', function(error, fd) { 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'); throw new Error('data event should not emit');
}); });
var readEmit = false; read.once('end', function endEvent2() {
read.once('end', function() { throw new Error('end event should not emit');
readEmit = true;
console.error('end event 2');
}); });
setTimeout(function() { setTimeout(function() {
assert.equal(readEmit, false); assert.equal(read.isPaused(), true);
}, common.platformTimeout(50)); }, common.platformTimeout(50));
}); });

Loading…
Cancel
Save