Skip to content

Commit

Permalink
Merge pull request socketio#2399 from nkzawa/graceful-close
Browse files Browse the repository at this point in the history
Add a test for graceful shutdown
  • Loading branch information
rauchg committed Jan 21, 2016
2 parents 2a91fd5 + a75f46f commit 198b836
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "mocha --reporter dot --slow 200ms --bail"
},
"dependencies": {
"engine.io": "1.6.7",
"engine.io": "nkzawa/engine.io#graceful-close",
"socket.io-parser": "2.2.6",
"socket.io-client": "1.4.4",
"socket.io-adapter": "0.4.0",
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/server-close.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var server = require('http').createServer();
var ioc = require('socket.io-client');
var io = require('../..')(server);

var srv = server.listen(function() {
var socket = ioc('ws://localhost:' + server.address().port);
socket.on('connect', function() {
io.close();
socket.close();
});
});
11 changes: 11 additions & 0 deletions test/socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var http = require('http').Server;
var io = require('..');
var fs = require('fs');
var join = require('path').join;
var exec = require('child_process').exec;
var ioc = require('socket.io-client');
var request = require('supertest');
var expect = require('expect.js');
Expand Down Expand Up @@ -412,6 +413,16 @@ describe('socket.io', function(){
});
});

describe('graceful close', function(){
function fixture(filename) {
return process.execPath + ' ' +
join(__dirname, 'fixtures', filename);
}

it('should stop socket and timers', function(done){
exec(fixture('server-close.js'), done);
});
});
});

describe('namespaces', function(){
Expand Down

0 comments on commit 198b836

Please sign in to comment.