Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

test: add test for #1869

fs.readdir() on file should raise ENOTDIR, not UNKNOWN.
  • Loading branch information...
bnoordhuis committed Oct 12, 2011
1 parent 752571c commit c82828ec278c3792ada33d60414da76c3d20b6b1
Showing with 31 additions and 0 deletions.
  1. +31 −0 test/simple/test-readdir.js
@@ -58,3 +58,34 @@ process.addListener('exit', function() {
assert.equal(false, got_error);
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);
});
})();

0 comments on commit c82828e

Please sign in to comment.
You can’t perform that action at this time.