Skip to content

Commit

Permalink
[test] Basic CLI tests with some helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki authored and indexzero committed Nov 23, 2011
1 parent d6b6c58 commit feade6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
27 changes: 3 additions & 24 deletions test/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ var fs = require('fs'),
helpers = require('./helpers'),
forever = require('../lib/forever');

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

vows.describe('forever/cli').addBatch({
'When using forever CLI': {
'and starting script using `forever start`': helpers.spawn(['start', script], {
'`forever.list` result': helpers.list({
'should contain spawned process': function (list) {
helpers.assertList(list);
assert.isNotNull(list);
assert.lengthOf(list, 1);
assert.equal(list[0].command, 'node');
assert.equal(fs.realpathSync(list[0].file), fs.realpathSync(script));
helpers.assertStartsWith(list[0].logFile, forever.config.get('root'));
Expand All @@ -36,26 +36,5 @@ vows.describe('forever/cli').addBatch({
})
})
}
}).addBatch({
'When using forever CLI': {
'and starting script using `forever start` with arguments': helpers.spawn(['start', script].concat(options), {
'`forever.list` result': helpers.list({
'should contain spawned process with proper options': function (list) {
helpers.assertList(list);
assert.notEqual(list[0].uid, 'itShouldNotGoToUIDField');
assert.deepEqual(list[0].options, options);
}
})
})
}
}).addBatch({
'When testing forever CLI': {
'necessary cleanup': {
topic: function () {
forever.stopAll().on('stopAll', this.callback.bind({}, null));
},
'should take place': function () {}
}
}
}).export(module);

11 changes: 3 additions & 8 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

var assert = require('assert'),
path = require('path'),
spawn = require('child_process').spawn,
forever = require('../lib/forever');

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

helpers.assertStartsWith = function (string, substring) {
assert.equal(string.slice(0, substring.length), substring);
};

helpers.assertList = function (list) {
assert.isNotNull(list);
assert.lengthOf(list, 1);
};

>>>>>>> d07b6dc... [test] Add test for option parsing
};

0 comments on commit feade6c

Please sign in to comment.