tail-stopall-test.js
1.28 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
/*
* tail-stopall-test.js: Tests for forever.tail() and forever.stopAll()
*
* (C) 2010 Charlie Robbins & the Contributors
* MIT LICENCE
*
*/
var assert = require('assert'),
path = require('path'),
spawn = require('child_process').spawn,
vows = require('vows'),
forever = require('../../lib/forever');
vows.describe('forever/core/tail').addBatch({
"When using forever": {
"the tail() method": {
topic: function () {
var that = this;
that.child = spawn('node', [path.join(__dirname, '..', 'fixtures', 'start-daemon.js')]);
setTimeout(function () {
forever.tail(0, { length: 1 }, that.callback);
}, 2000);
},
"should respond with logs for the script": function (err, procs) {
assert.isNull(err);
assert.equal(typeof procs, 'object');
assert.ok(procs.file);
assert.ok(procs.pid);
assert.ok(procs.line);
}
}
}
}).addBatch({
"When the tests are over": {
"stop all forever processes": {
topic: function () {
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);