forked from foreversd/forever
/
forever-test.js
58 lines (53 loc) · 1.6 KB
/
forever-test.js
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
52
53
54
55
56
57
58
/*
* forever-test.js: Tests for forever module
*
* (C) 2010 and Charlie Robbins
* MIT LICENCE
*
*/
require.paths.unshift(require('path').join(__dirname, '..', 'lib'));
var sys = require('sys'),
assert = require('assert'),
path = require('path'),
vows = require('vows'),
forever = require('forever');
vows.describe('forever').addBatch({
"When using forever": {
"and instance of Forever passed valid options": {
topic: function () {
var child = new (forever.Forever)('any-file.js', {
max: 10,
silent: true,
options: []
});
// Emit a useless callback since we can't return
// an instance of an events.EventEmitter
child.on('test', this.callback);
child.emit('test', null, child);
},
"should have correct properties set": function (err, child) {
assert.isNotNull(child.options);
assert.equal(child.options.max, 10);
assert.isTrue(child.options.silent);
assert.isArray(child.options.options);
assert.isFunction(child.run);
}
}
},
"when running error-on-timer sample three times": {
topic: function () {
var child = new (forever.Forever)(path.join(__dirname, '..', 'samples', 'error-on-timer.js'), {
max: 3,
silent: true,
outfile: 'test/stdout.log',
errfile: 'test/stderr.log',
options: []
});
child.on('exit', this.callback);
child.run();
},
"should emit 'exit' when completed": function (err, child) {
assert.equal(child.times, 3);
}
}
}).export(module);