Skip to content

Commit

Permalink
test: test mode passed as an options object in mkdir/mkdirSync
Browse files Browse the repository at this point in the history
Add tests for mode passed as an options object in fs.mkdir() and
fs.mkdirSync().

This also adds coverage for mkdirSync() inside the conditional where
options.mode is not undefined.

PR-URL: #37008
Refs: https://coverage.nodejs.org/coverage-e3e054d020ee5ef6/lib/fs.js.html#L1023
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
RaisinTen authored and targos committed May 1, 2021
1 parent a1ee9b3 commit 0e1963c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/parallel/test-fs-mkdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ function nextdir() {
}));
}

// fs.mkdir creates directory with mode passed as an options object
{
const pathname = path.join(tmpdir.path, nextdir());

fs.mkdir(pathname, { mode: 0o777 }, common.mustCall(function(err) {
assert.strictEqual(err, null);
assert.strictEqual(fs.existsSync(pathname), true);
}));
}

// fs.mkdirSync creates directory with mode passed as an options object
{
const pathname = path.join(tmpdir.path, nextdir());

fs.mkdirSync(pathname, { mode: 0o777 });

assert.strictEqual(fs.existsSync(pathname), true);
}

// mkdirSync successfully creates directory from given path
{
const pathname = path.join(tmpdir.path, nextdir());
Expand Down

0 comments on commit 0e1963c

Please sign in to comment.