Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1486 from akshayp/master
Add a test for the forever agent
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
var request = require('../index') | ||
, http = require('http') | ||
, tape = require('tape') | ||
|
||
var s = http.createServer(function(req, res) { | ||
res.statusCode = 200 | ||
res.end('ok') | ||
}) | ||
|
||
tape('setup', function(t) { | ||
s.listen(6767, function() { | ||
t.end() | ||
}) | ||
}) | ||
|
||
tape('should work with forever agent', function(t) { | ||
var r = request.forever({maxSockets: 1}) | ||
|
||
r({ | ||
url: 'http://localhost:6767', | ||
headers: { 'Connection':'Close' } | ||
}, function(err, resp, body) { | ||
t.equal(err, null) | ||
t.equal(body, 'ok') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tape('cleanup', function(t) { | ||
s.close(function() { | ||
t.end() | ||
}) | ||
}) |