-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case of startDaemon() method - configuration inheritance issue.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* daemonic-inheritance-test.js: Tests for configuration inheritance of forever.startDaemon() | ||
* | ||
* (C) 2010 Nodejitsu Inc. | ||
* MIT LICENCE | ||
* | ||
*/ | ||
|
||
var assert = require('assert'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
spawn = require('child_process').spawn, | ||
vows = require('vows'), | ||
forever = require('../../lib/forever'); | ||
|
||
var myRoot = path.resolve(process.env.HOME, '.forever_root'); | ||
|
||
vows.describe('forever/core/startDaemon').addBatch({ | ||
"When using forever":{ | ||
"the startDaemon() method with customized configuration":{ | ||
topic:function () { | ||
!fs.existsSync(myRoot) && fs.mkdirSync(myRoot); | ||
|
||
forever.load({root:myRoot}); | ||
|
||
forever.startDaemon(path.join(__dirname, '..', 'fixtures', 'log-on-interval.js')); | ||
setTimeout(function (that) { | ||
forever.list(false, that.callback); | ||
}, 2000, this) | ||
//forever.tail(0, { length: 1 }, that.callback); | ||
}, | ||
"should respond with 1 process":function (err, procs) { | ||
assert.isNull(err); | ||
assert.isArray(procs); | ||
assert.equal(procs.length, 1); | ||
}, | ||
"and logs/pids/socks are all piping into the customized root":function (err, procs) { | ||
assert.equal(procs[0].logFile.indexOf(myRoot), 0); | ||
assert.equal(procs[0].pidFile.indexOf(myRoot), 0); | ||
assert.equal(procs[0].socket.indexOf(myRoot), 0); | ||
} | ||
} | ||
} | ||
}).addBatch({ | ||
"When the tests are over":{ | ||
"stop all forever processes":{ | ||
topic:function () { | ||
forever.load({root:myRoot}); | ||
forever.stopAll().on('stopAll', this.callback.bind(null, null)); | ||
}, | ||
"should stop the correct number of procs":function (err, procs) { | ||
assert.isArray(procs); | ||
assert.lengthOf(procs, 1); | ||
} | ||
} | ||
} | ||
}).export(module); |