Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / extract-zip / node_modules / mkdirp / test / rel.js
1 var mkdirp = require('../');
2 var path = require('path');
3 var fs = require('fs');
4 var exists = fs.exists || path.exists;
5 var test = require('tap').test;
6
7 test('rel', function (t) {
8     t.plan(5);
9     var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10     var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
11     var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
12     
13     var cwd = process.cwd();
14     process.chdir('/tmp');
15     
16     var file = [x,y,z].join('/');
17     
18     mkdirp(file, 0755, function (err) {
19         t.ifError(err);
20         exists(file, function (ex) {
21             t.ok(ex, 'file created');
22             fs.stat(file, function (err, stat) {
23                 t.ifError(err);
24                 process.chdir(cwd);
25                 t.equal(stat.mode & 0777, 0755);
26                 t.ok(stat.isDirectory(), 'target not a directory');
27             })
28         })
29     });
30 });