Skip to content

Commit

Permalink
test: fix nits in test-fs-mkdir-rmdir.js
Browse files Browse the repository at this point in the history
* Add common.mustCall().
* Add check for error existence, not only for error details.
* Use test(), not match() in a boolean context.
* Properly reverse meanings of assert messages.

PR-URL: #13680
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed Jul 17, 2017
1 parent 8f430e7 commit fa75be7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/parallel/test-fs-mkdir-rmdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ fs.rmdirSync(d);
assert(!common.fileExists(d));

// Similarly test the Async version
fs.mkdir(d, 0o666, function(err) {
fs.mkdir(d, 0o666, common.mustCall(function(err) {
assert.ifError(err);

fs.mkdir(d, 0o666, function(err) {
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
assert.strictEqual(err.code, 'EEXIST', 'got EEXIST code');
assert.strictEqual(err.path, d, 'got proper path for EEXIST');
fs.mkdir(d, 0o666, common.mustCall(function(err) {
assert.ok(err, 'got no error');
assert.ok(/^EEXIST/.test(err.message), 'got no EEXIST message');
assert.strictEqual(err.code, 'EEXIST', 'got no EEXIST code');
assert.strictEqual(err.path, d, 'got no proper path for EEXIST');

fs.rmdir(d, assert.ifError);
});
});
}));
}));

0 comments on commit fa75be7

Please sign in to comment.