Skip to content

Commit

Permalink
failing tests for versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Feb 2, 2012
1 parent e67a62c commit 89a0e52
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var seaport = require('../');
var test = require('tap').test;

test('versions', function (t) {
t.plan(5);

var serverPort = Math.floor(Math.random() * 5e5 + 1e5);
var server = seaport.createServer();
server.listen(serverPort);

var ports = [
seaport.connect(serverPort),
seaport.connect(serverPort),
seaport.connect(serverPort),
];

setTimeout(function () {
var pending = 3;
ports[0].get('beep', function (ps) {
t.equal(ps.length, 3);
if (--pending === 3) t.end();
});

ports[0].get('beep@1.2.x', function (ps) {
t.equal(ps.length, 1);
t.equal(ps[0].port, ports_['beep@1.2.3']);
if (--pending === 3) t.end();
});

ports[0].get('beep@>1.2', function (ps) {
t.equal(ps.length, 1);
t.equal(ps[0].port, ports_['beep@1.3.5']);
if (--pending === 3) t.end();
});
}, 250);

var ports_ = {};
setTimeout(function () {
ports[1].service('beep@1.2.3', function (port, ready) {
ports_['beep@1.2.3'] = port;
setTimeout(ready, 50);
});
ports[1].service('beep@1.3.5', function (port, ready) {
ports_['beep@1.3.5'] = port;
setTimeout(ready, 50);
});
ports[2].service('beep@0.9.2', function (port, ready) {
ports_['beep@0.9.2'] = port;
setTimeout(ready, 50);
});
}, 50);

t.on('end', function () {
server.close();
ports[0].close();
ports[1].close();
ports[2].close();
});
});

0 comments on commit 89a0e52

Please sign in to comment.