Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
added a test verifying this.requests is cleaned up on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Dec 5, 2012
1 parent 7c032a3 commit e1e9c6c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/endpoint_test.js
Expand Up @@ -176,7 +176,33 @@ describe("Endpoint", function () {
s.close() s.close()
assert.equal(fin, true) assert.equal(fin, true)
done() done()
}, 50) }, 60)
})
s.listen(6969)
})

it("removes the request from this.requests on timeout", function (done) {
var s = http.createServer(function (req, res) {
setTimeout(function () {
res.end("foo")
}, 30)
})
s.on('listening', function () {
var e = new Endpoint(http, '127.0.0.1', 6969, {keepAlive: true, timeout: 20, resolution: 10})
var fin = false
e.on('timeout', function () {
fin = true
})
e.request({path:'/foo', method: 'GET'}, noop)
e.request({path:'/foo', method: 'GET'}, noop)
e.request({path:'/foo', method: 'GET'}, noop)

setTimeout(function () {
assert.equal(fin, true)
assert.equal(Object.keys(e.requests).length, 0)
s.close()
done()
}, 100)
}) })
s.listen(6969) s.listen(6969)
}) })
Expand Down

0 comments on commit e1e9c6c

Please sign in to comment.