Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
/*
2
* directories-test.js: Tests for working with directories in broadway.
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var assert = require('assert'),
10
fs = require('fs'),
11
path = require('path'),
12
vows = require('vows'),
13
broadway = require('../../lib/broadway');
14
15
var fixturesDir = path.join(__dirname, '..', 'fixtures'),
16
emptyAppDir = path.join(fixturesDir, 'empty-app'),
17
emptyAppFile = path.join(fixturesDir, 'sample-app.json'),
18
appConfig = JSON.parse(fs.readFileSync(emptyAppFile, 'utf8')),
19
directories = appConfig.directories;
20
21
vows.describe('broadway/common/directories').addBatch({
22
"When using broadway.common.directories": {
23
"it should have the correct methods defined": function () {
24
assert.isObject(broadway.common.directories);
25
assert.isFunction(broadway.common.directories.create);
26
assert.isFunction(broadway.common.directories.remove);
27
},
28
"the normalize() method should correctly modify a set of directories": function () {
29
directories = broadway.common.directories.normalize({'#ROOT': emptyAppDir}, directories);
30
31
Object.keys(directories).forEach(function (key) {
32
assert.isTrue(directories[key].indexOf(emptyAppDir) !== -1);
33
});
34
},
35
"the create() method": {
36
topic: function () {
37
broadway.common.directories.create(directories, this.callback);
38
},
39
"should create the specified directories": function (err, dirs) {
40
assert.isTrue(!err);
41
42
var exists = false;
43
dirs.forEach(function (dir) {
44
exists = (fs.existsSync || path.existsSync)(dir);
45
});
46
47
assert.isTrue(exists);
48
},
49
"the destroy() method": {
50
topic: function () {
51
broadway.common.directories.remove(directories, this.callback);
52
},
53
"should remove the specified directories": function (err, dirs) {
54
assert.isTrue(!err);
55
56
var exists = true;
57
dirs.forEach(function (dir) {
58
exists = (fs.existsSync || path.existsSync)(dir);
59
});
60
61
assert.isFalse(exists);
62
}
63
}
64
}
65
}
66
}).export(module);
67
68