start-stop-json-obj-test.js
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* start-stop-json-test.js: start or stop forever using relative paths, the script path could be start with './', '../' ...
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
fs = require('fs'),
vows = require('vows'),
forever = require('../../lib/forever'),
runCmd = require('../helpers').runCmd;
vows.describe('forever/core/start-stop-json-obj').addBatch({
"When using forever" : {
"to start process using JSON configuration file containing an object" : {
topic: function () {
runCmd('start', [
'./test/fixtures/server.json'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the startup should works fine": function (err, procs) {
assert.isNull(err);
assert.isArray(procs);
assert.equal(procs.length, 1);
}
}
}
}).addBatch({
"When the script is running" : {
"try to stop by uid" : {
topic: function () {
runCmd('stop', [
'server'
]);
setTimeout(function (that) {
forever.list(false, that.callback);
}, 2000, this);
},
"the shut down should works fine": function (err, procs) {
assert.isNull(err);
assert.isNull(procs);
}
}
}
}).export(module);