Browse Source

test: add test for #1869

fs.readdir() on file should raise ENOTDIR, not UNKNOWN.
v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
c82828ec27
  1. 31
      test/simple/test-readdir.js

31
test/simple/test-readdir.js

@ -58,3 +58,34 @@ process.addListener('exit', function() {
assert.equal(false, got_error); assert.equal(false, got_error);
console.log('exit'); console.log('exit');
}); });
// readdir() on file should throw ENOTDIR
// https://github.com/joyent/node/issues/1869
(function() {
var has_caught = false;
try {
fs.readdirSync(__filename)
}
catch (e) {
has_caught = true;
assert.equal(e.code, 'ENOTDIR');
}
assert(has_caught);
})();
(function() {
var readdir_cb_called = false;
fs.readdir(__filename, function(e) {
readdir_cb_called = true;
assert.equal(e.code, 'ENOTDIR');
});
process.on('exit', function() {
assert(readdir_cb_called);
});
})();
Loading…
Cancel
Save