Permalink
Browse files

properly failing hub down up test

  • Loading branch information...
1 parent 7c7c0d5 commit db04e6b0b8680d5b912b5bcd893a308955b489b0 @substack committed Sep 30, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 test/hub_down_server_down.js
@@ -3,7 +3,7 @@ var seaport = require('seaport');
var spawn = require('child_process').spawn;
test('hub goes down, server goes down', function (t) {
- t.plan(1);
+ t.plan(2);
var port = Math.floor(Math.random() * 5e4 + 1e4);
@@ -23,28 +23,31 @@ test('hub goes down, server goes down', function (t) {
var data = '';
ps.client.stdout.on('data', function (buf) { data += buf });
function checkOutput () {
- t.same(data.split(/\r?\n/), [ 'up', 'down', 'up', '' ]);
+ t.same(data.split(/\r?\n/).slice(-3)[0], 'down');
+ t.same(data.split(/\r?\n/).slice(-2)[0], 'up');
}
setTimeout(function () {
+ ps.hub.kill();
ps.server.kill();
- }, 2 * 1000);
+ }, 1000);
setTimeout(function () {
- ps.hub.kill();
- }, 4 * 1000);
+ ps.hub = sh('hub.js');
+ }, 2.5 * 1000);
setTimeout(function () {
+ ps.hub.kill();
ps.hub = sh('hub.js');
- }, 6 * 1000);
+ }, 4 * 1000);
setTimeout(function () {
ps.server = sh('server.js');
- }, 10 * 1000);
+ }, 4.5 * 1000);
setTimeout(function () {
checkOutput();
- }, 15 * 1000);
+ }, 8 * 1000);
t.on('end', function () {
ps.hub.kill();

0 comments on commit db04e6b

Please sign in to comment.