Skip to content

Commit

Permalink
test: test sync version of mkdir & rmdir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
thefourtheye authored and rvagg committed Sep 22, 2015
1 parent 8da3da4 commit 4519dd0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
37 changes: 37 additions & 0 deletions test/parallel/test-fs-mkdir-rmdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'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.equal(err.code, 'EEXIST', 'got EEXIST code');
assert.equal(err.path, d, 'got proper path for EEXIST');

fs.rmdir(d, assert.ifError);
});
});
43 changes: 0 additions & 43 deletions test/sequential/test-mkdir-rmdir.js

This file was deleted.

0 comments on commit 4519dd0

Please sign in to comment.