Skip to content

Commit

Permalink
test: test error messages from fs.realpath{Sync}
Browse files Browse the repository at this point in the history
PR-URL: #17914
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung committed Jan 16, 2018
1 parent 5eccbb0 commit 1312db5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/parallel/test-fs-error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ fs.lstat(fn, common.mustCall((err) => {
}));
}

fs.realpath(fn, common.mustCall((err) => {
assert.strictEqual(fn, err.path);
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, lstat '${fn}'`);
assert.strictEqual(err.errno, uv.UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'lstat');
}));

fs.readlink(fn, common.mustCall((err) => {
assert.ok(err.message.includes(fn));
}));
Expand Down Expand Up @@ -181,6 +191,20 @@ try {
assert.strictEqual(err.syscall, 'fstat');
}

try {
++expected;
fs.realpathSync(fn);
} catch (err) {
errors.push('realpath');
assert.strictEqual(fn, err.path);
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, lstat '${fn}'`);
assert.strictEqual(err.errno, uv.UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'lstat');
}

try {
++expected;
fs.readlinkSync(fn);
Expand Down

0 comments on commit 1312db5

Please sign in to comment.