Skip to content

Commit

Permalink
Merge pull request #1486 from akshayp/master
Browse files Browse the repository at this point in the history
Add a test for the forever agent
  • Loading branch information
simov committed Mar 23, 2015
2 parents f33d1a6 + 4b01584 commit ed6d53e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"bl": "~0.9.0",
"caseless": "~0.9.0",
"forever-agent": "~0.5.0",
"forever-agent": "~0.6.0",
"form-data": "~0.2.0",
"json-stringify-safe": "~5.0.0",
"mime-types": "~2.0.1",
Expand Down
35 changes: 35 additions & 0 deletions tests/test-agent.js
@@ -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()
})
})

0 comments on commit ed6d53e

Please sign in to comment.