Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / coffee-script / node_modules / mkdirp / test / chmod.js
1 var mkdirp = require('../').mkdirp;
2 var path = require('path');
3 var fs = require('fs');
4 var test = require('tap').test;
5
6 var ps = [ '', 'tmp' ];
7
8 for (var i = 0; i < 25; i++) {
9     var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10     ps.push(dir);
11 }
12
13 var file = ps.join('/');
14
15 test('chmod-pre', function (t) {
16     var mode = 0744
17     mkdirp(file, mode, function (er) {
18         t.ifError(er, 'should not error');
19         fs.stat(file, function (er, stat) {
20             t.ifError(er, 'should exist');
21             t.ok(stat && stat.isDirectory(), 'should be directory');
22             t.equal(stat && stat.mode & 0777, mode, 'should be 0744');
23             t.end();
24         });
25     });
26 });
27
28 test('chmod', function (t) {
29     var mode = 0755
30     mkdirp(file, mode, function (er) {
31         t.ifError(er, 'should not error');
32         fs.stat(file, function (er, stat) {
33             t.ifError(er, 'should exist');
34             t.ok(stat && stat.isDirectory(), 'should be directory');
35             t.end();
36         });
37     });
38 });