|
| 1 | +/* |
| 2 | + * cli-test.js: Tests for forever CLI |
| 3 | + * |
| 4 | + * (C) 2011 Nodejitsu Inc. |
| 5 | + * MIT LICENCE |
| 6 | + * |
| 7 | + */ |
| 8 | + |
| 9 | +var fs = require('fs'), |
| 10 | + path = require('path'), |
| 11 | + assert = require('assert'), |
| 12 | + vows = require('vows'), |
| 13 | + helpers = require('./helpers'), |
| 14 | + forever = require('../lib/forever'); |
| 15 | + |
| 16 | +var script = path.join(__dirname, '..', 'examples', 'log-on-interval.js'), |
| 17 | + options = ['--uid', 'itShouldNotGoToUIDField']; |
| 18 | + |
| 19 | +vows.describe('forever/cli').addBatch({ |
| 20 | + 'When using forever CLI': { |
| 21 | + 'and starting script using `forever start`': helpers.spawn(['start', script], { |
| 22 | + '`forever.list` result': helpers.list({ |
| 23 | + 'should contain spawned process': function (list) { |
| 24 | + helpers.assertList(list); |
| 25 | + assert.equal(list[0].command, 'node'); |
| 26 | + assert.equal(fs.realpathSync(list[0].file), fs.realpathSync(script)); |
| 27 | + helpers.assertStartsWith(list[0].logFile, forever.config.get('root')); |
| 28 | + }, |
| 29 | + 'and stopping it using `forever stop`': helpers.spawn(['stop', script], { |
| 30 | + '`forever.list` result': helpers.list({ |
| 31 | + 'should not contain previous process': function (list) { |
| 32 | + assert.isNull(list); |
| 33 | + } |
| 34 | + }) |
| 35 | + }) |
| 36 | + }) |
| 37 | + }) |
| 38 | + } |
| 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 | +}).export(module); |
| 52 | + |
0 commit comments