diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index bf8a1f2f6a050c..fac430bbe227e1 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -371,7 +371,7 @@ async function chmod(path, mode) { async function lchmod(path, mode) { if (O_SYMLINK === undefined) - throw new ERR_METHOD_NOT_IMPLEMENTED(); + throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()'); const fd = await open(path, O_WRONLY | O_SYMLINK); return fchmod(fd, mode).finally(fd.close.bind(fd)); diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js index 6871a6762b68e2..602f1191b7aef5 100644 --- a/test/parallel/test-fs-promises.js +++ b/test/parallel/test-fs-promises.js @@ -140,15 +140,26 @@ function verifyStatObject(stat) { (await realpath(newLink)).toLowerCase()); assert.strictEqual(newPath.toLowerCase(), (await readlink(newLink)).toLowerCase()); + + const newMode = 0o666; if (common.isOSX) { // lchmod is only available on macOS - const newMode = 0o666; await lchmod(newLink, newMode); stats = await lstat(newLink); assert.strictEqual(stats.mode & 0o777, newMode); + } else { + await Promise.all([ + assert.rejects( + lchmod(newLink, newMode), + common.expectsError({ + code: 'ERR_METHOD_NOT_IMPLEMENTED', + type: Error, + message: 'The lchmod() method is not implemented' + }) + ) + ]); } - await unlink(newLink); }