0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/tool/shell_mkdir.js
2019-07-27 11:02:23 -04:00

36 lines
924 B
JavaScript

// Test the shell's mkdir utility.
(function() {
"use strict";
var dir = MongoRunner.dataPath + "ShellMkdirTestDirectory";
removeFile(dir);
// Make a new directory
var res = mkdir(dir);
printjson(res);
assert(res);
assert(res["exists"]);
assert(res["created"]);
// Make the same directory again
res = mkdir(dir);
printjson(res);
assert(res);
assert(res["exists"]);
assert(!res["created"]);
// Check that we throw, rather than crash, on ""
// (see https://svn.boost.org/trac/boost/ticket/12495)
assert.throws(function() {
mkdir("");
}, [], "");
removeFile(dir);
// check that other internal path functions do not crash on ""
assert(pathExists("") === false, "expected pathExists to return false on empty path");
assert(copyDbpath("", "") === undefined, "expected copyDbpath to return undefined on empty path");
assert(resetDbpath("") === undefined, "expected resetDbpath to return undefined on empty path");
}());