Skip to content
This repository
Browse code

half open test now fails when the request doesn't come all on the fir…

…st tick
  • Loading branch information...
commit a62d0ee386deee5f240f7d60c382ec84bdf22ef9 1 parent b1bedf1
James Halliday authored December 16, 2012

Showing 1 changed file with 14 additions and 4 deletions. Show diff stats Hide diff stats

  1. 18  test/half_open.js
18  test/half_open.js
@@ -15,7 +15,11 @@ var proxy = bouncy(function (req, res, bounce) {
15 15
 proxy.listen(0);
16 16
 
17 17
 var server = http.createServer(function (req, res) {
18  
-    res.end('beep boop\n');
  18
+    res.write('beep ');
  19
+    
  20
+    setTimeout(function () {
  21
+        res.end('boop.');
  22
+    }, 100);
19 23
 });
20 24
 server.listen(0);
21 25
 
@@ -27,9 +31,15 @@ test('half-open', function (t) {
27 31
     c.on('data', function (buf) { data += buf });
28 32
     c.on('end', function () {
29 33
         var lines = data.split(/\r?\n/);
30  
-        t.ok(lines.some(function (line) {
31  
-            return line === 'beep boop';
32  
-        }));
  34
+        for (var ix = 0; lines[ix] !== ''; ix++);
  35
+        
  36
+        t.same(lines.slice(ix), [
  37
+            '5',
  38
+            'beep ',
  39
+            '5',
  40
+            'boop.',
  41
+            '0'
  42
+        ]);
33 43
     });
34 44
     
35 45
     c.end([

0 notes on commit a62d0ee

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