Permalink
Browse files

http test

  • Loading branch information...
1 parent 6454ab0 commit 7931f1e6d1baa968779c159c6d93d97e29ae9e9d @substack committed Jan 14, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 test/http.js
View
@@ -0,0 +1,37 @@
+var test = require('tap').test;
+var toss = require('../');
+var http = require('http');
+
+test('http request timeout failure', function (t) {
+ var port = Math.floor(Math.random() * 5e5 + 1e4);
+ var tt = toss(200, function (err) {
+ t.ok(err);
+ t.end();
+ });
+
+ function get (cb) {
+ http.get({ port : port, path : '/' }, function (res) {
+ res.on('end', cb);
+ });
+ }
+
+ function ready () {
+ get(tt(function () {
+ get(tt(function () {
+ console.log('finished');
+ tt.end();
+ }));
+ }));
+ }
+
+ var server = http.createServer(function (req, res) {
+ setTimeout(function () {
+ res.end('beeeeeeeeeeeeeeeeeeeeeeeeep');
+ }, 600);
+ });
+ server.listen(port, ready);
+
+ t.on('end', function () {
+ server.close();
+ });
+});

0 comments on commit 7931f1e

Please sign in to comment.