mirror of
https://github.com/nodejs/node.git
synced 2025-05-12 03:10:50 +00:00

Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
38 lines
1023 B
JavaScript
38 lines
1023 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const d = path.join(common.tmpDir, 'dir');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
// Make sure the directory does not exist
|
|
assert(!common.fileExists(d));
|
|
// Create the directory now
|
|
fs.mkdirSync(d);
|
|
// Make sure the directory exists
|
|
assert(common.fileExists(d));
|
|
// Try creating again, it should fail with EEXIST
|
|
assert.throws(function() {
|
|
fs.mkdirSync(d);
|
|
}, /EEXIST: file already exists, mkdir/);
|
|
// Remove the directory now
|
|
fs.rmdirSync(d);
|
|
// Make sure the directory does not exist
|
|
assert(!common.fileExists(d));
|
|
|
|
// Similarly test the Async version
|
|
fs.mkdir(d, 0o666, 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.rmdir(d, assert.ifError);
|
|
});
|
|
});
|