Permalink
Browse files

also test assume()

  • Loading branch information...
1 parent 4384dce commit a2521f0d3a2d77f6753f8c924719073731a87e37 @substack committed Jan 27, 2012
Showing with 14 additions and 5 deletions.
  1. +14 −5 test/alloc.js
View
@@ -2,7 +2,7 @@ var test = require('tap').test;
var seaport = require('../');
test('alloc and free', function (t) {
- t.plan(3);
+ t.plan(4);
var port = Math.floor(Math.random() * 5e5 + 1e4);
var server = seaport.createServer();
@@ -11,6 +11,19 @@ test('alloc and free', function (t) {
gotPort = alloc.port;
});
+ server.on('free', function () {
+ ports = seaport('staging').connect('localhost', port);
+ ports.assume('http', gotPort);
+ });
+
+ server.on('assume', function (alloc) {
+ t.equal(alloc.port, gotPort);
+
+ ports.close();
+ server.close();
+ t.end();
+ });
+
server.listen(port);
var ports = seaport('staging').connect('localhost', port);
@@ -21,11 +34,7 @@ test('alloc and free', function (t) {
ports.query('http', function (ps) {
t.deepEqual(ps, [ { host : '127.0.0.1', port : p } ]);
-
- server.end();
- server.close();
ports.close();
- t.end();
});
});
});

0 comments on commit a2521f0

Please sign in to comment.