diff --git a/tests/test-pool.js b/tests/test-pool.js index a3fea7eb7..b59bd3362 100644 --- a/tests/test-pool.js +++ b/tests/test-pool.js @@ -31,26 +31,30 @@ tape('pool', function(t) { }) tape('forever', function(t) { - var d = require('domain').create() + var r = request({ + url: 'http://localhost:6767', + forever: true, + pool: {maxSockets: 1024} + }, function(err, res, body) { + // explicitly shut down the agent + if (r.agent.destroy === typeof 'function') { + r.agent.destroy() + } else { + // node < 0.12 + Object.keys(r.agent.sockets).forEach(function (name) { + r.agent.sockets[name].forEach(function (socket) { + socket.end() + }) + }) + } - d.on('error', function(err){ - t.fail(err) - }) + t.equal(err, null) + t.equal(res.statusCode, 200) + t.equal(body, 'asdf') - d.run(function(){ - request({ - url: 'http://localhost:6767', - forever: true, - pool: {maxSockets: 1024} - }, function(err, res, body) { - t.equal(err, null) - t.equal(res.statusCode, 200) - t.equal(body, 'asdf') - - var agent = res.request.agent - t.equal(agent.maxSockets, 1024) - t.end() - }) + var agent = res.request.agent + t.equal(agent.maxSockets, 1024) + t.end() }) })