Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4519dd0

Browse filesBrowse 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 <me@silverwind.io> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
1 parent 8da3da4 commit 4519dd0
Copy full SHA for 4519dd0

File tree

Expand file treeCollapse file tree

2 files changed

+37
-43
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+37
-43
lines changed
Open diff view settings
Collapse file
+37Lines changed: 37 additions & 0 deletions
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+
});
Collapse file

‎test/sequential/test-mkdir-rmdir.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-mkdir-rmdir.js
-43Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.