Permalink
Browse files

added a test verifying this.requests is cleaned up on timeout

  • Loading branch information...
1 parent 7c032a3 commit e1e9c6ce8b4d58bd6af2422f4715543aa19f1ac2 @dannycoates committed Dec 5, 2012
Showing with 27 additions and 1 deletion.
  1. +27 −1 test/endpoint_test.js
View
@@ -176,7 +176,33 @@ describe("Endpoint", function () {
s.close()
assert.equal(fin, true)
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)
})

0 comments on commit e1e9c6c

Please sign in to comment.