Skip to content

Commit 4519dd0

Browse files
thefourtheyervagg
authored andcommitted
test: test sync version of mkdir & rmdir
This patch includes tests for sync versions of mkdir and rmdir. Also, it moves the test to `parallel`. PR-URL: #2588 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Johan Bergström <[email protected]>
1 parent 8da3da4 commit 4519dd0

File tree

2 files changed

+37
-43
lines changed

2 files changed

+37
-43
lines changed

test/parallel/test-fs-mkdir-rmdir.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const path = require('path');
6+
const fs = require('fs');
7+
const d = path.join(common.tmpDir, 'dir');
8+
9+
common.refreshTmpDir();
10+
11+
// Make sure the directory does not exist
12+
assert(!common.fileExists(d));
13+
// Create the directory now
14+
fs.mkdirSync(d);
15+
// Make sure the directory exists
16+
assert(common.fileExists(d));
17+
// Try creating again, it should fail with EEXIST
18+
assert.throws(function() {
19+
fs.mkdirSync(d);
20+
}, /EEXIST: file already exists, mkdir/);
21+
// Remove the directory now
22+
fs.rmdirSync(d);
23+
// Make sure the directory does not exist
24+
assert(!common.fileExists(d));
25+
26+
// Similarly test the Async version
27+
fs.mkdir(d, 0o666, function(err) {
28+
assert.ifError(err);
29+
30+
fs.mkdir(d, 0o666, function(err) {
31+
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
32+
assert.equal(err.code, 'EEXIST', 'got EEXIST code');
33+
assert.equal(err.path, d, 'got proper path for EEXIST');
34+
35+
fs.rmdir(d, assert.ifError);
36+
});
37+
});

test/sequential/test-mkdir-rmdir.js

-43
This file was deleted.

0 commit comments

Comments
 (0)