Skip to content

Commit feade6c

Browse files
mmaleckiindexzero
authored andcommitted
[test] Basic CLI tests with some helpers
1 parent d6b6c58 commit feade6c

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

test/cli-test.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ var fs = require('fs'),
1313
helpers = require('./helpers'),
1414
forever = require('../lib/forever');
1515

16-
var script = path.join(__dirname, '..', 'examples', 'log-on-interval.js'),
17-
options = ['--uid', 'itShouldNotGoToUIDField'];
16+
var script = path.join(__dirname, '..', 'examples', 'log-on-interval.js');
1817

1918
vows.describe('forever/cli').addBatch({
2019
'When using forever CLI': {
2120
'and starting script using `forever start`': helpers.spawn(['start', script], {
2221
'`forever.list` result': helpers.list({
2322
'should contain spawned process': function (list) {
24-
helpers.assertList(list);
23+
assert.isNotNull(list);
24+
assert.lengthOf(list, 1);
2525
assert.equal(list[0].command, 'node');
2626
assert.equal(fs.realpathSync(list[0].file), fs.realpathSync(script));
2727
helpers.assertStartsWith(list[0].logFile, forever.config.get('root'));
@@ -36,26 +36,5 @@ vows.describe('forever/cli').addBatch({
3636
})
3737
})
3838
}
39-
}).addBatch({
40-
'When using forever CLI': {
41-
'and starting script using `forever start` with arguments': helpers.spawn(['start', script].concat(options), {
42-
'`forever.list` result': helpers.list({
43-
'should contain spawned process with proper options': function (list) {
44-
helpers.assertList(list);
45-
assert.notEqual(list[0].uid, 'itShouldNotGoToUIDField');
46-
assert.deepEqual(list[0].options, options);
47-
}
48-
})
49-
})
50-
}
51-
}).addBatch({
52-
'When testing forever CLI': {
53-
'necessary cleanup': {
54-
topic: function () {
55-
forever.stopAll().on('stopAll', this.callback.bind({}, null));
56-
},
57-
'should take place': function () {}
58-
}
59-
}
6039
}).export(module);
6140

test/helpers.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
var assert = require('assert'),
10+
path = require('path'),
11+
spawn = require('child_process').spawn,
1012
forever = require('../lib/forever');
1113

1214
var helpers = exports;
@@ -64,11 +66,4 @@ helpers.list = function (options) {
6466

6567
helpers.assertStartsWith = function (string, substring) {
6668
assert.equal(string.slice(0, substring.length), substring);
67-
};
68-
69-
helpers.assertList = function (list) {
70-
assert.isNotNull(list);
71-
assert.lengthOf(list, 1);
72-
};
73-
74-
>>>>>>> d07b6dc... [test] Add test for option parsing
69+
};

0 commit comments

Comments
 (0)