~ps-jenkins/ubuntu-push/ubuntu-vivid-proposed

« back to all changes in this revision

Viewing changes to docs/example-server/node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/rel.js

  • Committer: Roberto Alsina
  • Date: 2014-09-05 14:57:17 UTC
  • mto: (91.179.25 automatic)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: roberto.alsina@canonical.com-20140905145717-0ufcsv27w25i1nnu
added example app server

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var mkdirp = require('../');
 
2
var path = require('path');
 
3
var fs = require('fs');
 
4
var test = require('tap').test;
 
5
 
 
6
test('rel', function (t) {
 
7
    t.plan(2);
 
8
    var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
 
9
    var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
 
10
    var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
 
11
    
 
12
    var cwd = process.cwd();
 
13
    process.chdir('/tmp');
 
14
    
 
15
    var file = [x,y,z].join('/');
 
16
    
 
17
    mkdirp(file, 0755, function (err) {
 
18
        if (err) t.fail(err);
 
19
        else path.exists(file, function (ex) {
 
20
            if (!ex) t.fail('file not created')
 
21
            else fs.stat(file, function (err, stat) {
 
22
                if (err) t.fail(err)
 
23
                else {
 
24
                    process.chdir(cwd);
 
25
                    t.equal(stat.mode & 0777, 0755);
 
26
                    t.ok(stat.isDirectory(), 'target not a directory');
 
27
                    t.end();
 
28
                }
 
29
            })
 
30
        })
 
31
    });
 
32
});