diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-28 01:45:17 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-03-02 21:13:24 +0800 |
commit | 1650eaeac4d344a21f08923dc39ab09637f71ab8 (patch) | |
tree | 93abc12cc53f9dcca6d70fc9f4292e1b9996952d /test | |
parent | 79b195437c007162e0ebf5b24f3f38f8d369e267 (diff) | |
download | android-node-v8-1650eaeac4d344a21f08923dc39ab09637f71ab8.tar.gz android-node-v8-1650eaeac4d344a21f08923dc39ab09637f71ab8.tar.bz2 android-node-v8-1650eaeac4d344a21f08923dc39ab09637f71ab8.zip |
fs: throw fchownSync errors in JS
PR-URL: https://github.com/nodejs/node/pull/19041
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-fs-error-messages.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index d14a5b8eff..1aa4e12294 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -749,3 +749,24 @@ if (!common.isAIX) { ); }); } + +// fchown +if (!common.isWindows) { + const validateError = (err) => { + assert.strictEqual(err.message, 'EBADF: bad file descriptor, fchown'); + assert.strictEqual(err.errno, uv.UV_EBADF); + assert.strictEqual(err.code, 'EBADF'); + assert.strictEqual(err.syscall, 'fchown'); + return true; + }; + + common.runWithInvalidFD((fd) => { + fs.fchown(fd, process.getuid(), process.getgid(), + common.mustCall(validateError)); + + assert.throws( + () => fs.fchownSync(fd, process.getuid(), process.getgid()), + validateError + ); + }); +} |