arnaucube
arnaucube/comunicationLeapPublic Self-hosted repository
comunicationLeap/node_modules/mkdirp/test/perm_sync.js
node_modules/mkdirp/test/perm_sync.jsRaw
 1var mkdirp = require('../');
 2var path = require('path');
 3var fs = require('fs');
 4var test = require('tap').test;
 5
 6test('sync perm', function (t) {
 7    t.plan(2);
 8    var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json';
 9    
10    mkdirp.sync(file, 0755);
11    path.exists(file, function (ex) {
12        if (!ex) t.fail('file not created')
13        else fs.stat(file, function (err, stat) {
14            if (err) t.fail(err)
15            else {
16                t.equal(stat.mode & 0777, 0755);
17                t.ok(stat.isDirectory(), 'target not a directory');
18                t.end();
19            }
20        })
21    });
22});
23
24test('sync root perm', function (t) {
25    t.plan(1);
26    
27    var file = '/tmp';
28    mkdirp.sync(file, 0755);
29    path.exists(file, function (ex) {
30        if (!ex) t.fail('file not created')
31        else fs.stat(file, function (err, stat) {
32            if (err) t.fail(err)
33            else {
34                t.ok(stat.isDirectory(), 'target not a directory');
35                t.end();
36            }
37        })
38    });
39});