perm.js 804 B

1234567891011121314151617181920212223242526272829303132
  1. /* Tests borrowed from substack's node-mkdirp
  2. * https://github.com/substack/node-mkdirp */
  3. var mkpath = require('../');
  4. var fs = require('fs');
  5. var test = require('tap').test;
  6. test('async perm', function (t) {
  7. t.plan(2);
  8. var file = '/tmp/' + (Math.random() * (1<<30)).toString(16);
  9. mkpath(file, 0755, function (err) {
  10. if (err) t.fail(err);
  11. else fs.stat(file, function (err, stat) {
  12. if (err) t.fail(err)
  13. else {
  14. t.equal(stat.mode & 0777, 0755);
  15. t.ok(stat.isDirectory(), 'target not a directory');
  16. t.end();
  17. }
  18. })
  19. });
  20. });
  21. test('async root perm', function (t) {
  22. mkpath('/tmp', 0755, function (err) {
  23. if (err) t.fail(err);
  24. t.end();
  25. });
  26. t.end();
  27. });