Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

test that hangs

  • Loading branch information...
commit 90404bdc3e22d4f35fdf190b3eea563410dd69e2 1 parent e061764
James Halliday authored July 10, 2012

Showing 1 changed file with 40 additions and 0 deletions. Show diff stats Hide diff stats

  1. 40  test/cache.js
40  test/cache.js
... ...
@@ -0,0 +1,40 @@
  1
+var test = require('tap').test;
  2
+var seaport = require('seaport');
  3
+var pier = require('../');
  4
+
  5
+test('up and down', function (t) {
  6
+    t.plan(10);
  7
+    var port = Math.floor(1e4 + 5e4 * Math.random());
  8
+    
  9
+    var server = seaport.createServer().listen(port);
  10
+    var cache = pier().tie(port);
  11
+    var ports = seaport.connect(port);
  12
+    
  13
+    t.on('end', function () {
  14
+        console.log('end');
  15
+        ports.close();
  16
+        server.close();
  17
+        cache.close();
  18
+    });
  19
+    
  20
+    setTimeout(function () {
  21
+        t.same([], cache.query());
  22
+        ports.assume('beep', 9999);
  23
+        
  24
+        function cmp (records) {
  25
+            t.equal(records.length, 1);
  26
+            t.equal(records[0].host, '127.0.0.1');
  27
+            t.equal(records[0].port, 9999);
  28
+            t.equal(records[0].role, 'beep');
  29
+        }
  30
+        cache.once('update', function (records) {
  31
+            cmp(records);
  32
+            cmp(cache.query('beep'));
  33
+            
  34
+            cache.once('update', function (records) {
  35
+                t.same(records, []);
  36
+            });
  37
+            ports.free({ role : 'beep', port : 9999 });
  38
+        });
  39
+    }, 100);
  40
+});

0 notes on commit 90404bd

Please sign in to comment.
Something went wrong with that request. Please try again.