Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: simplify tests with the common module
  • Loading branch information
collin5 committed Dec 8, 2017
commit 8f0dd5ce5013ec36a8938a18250e9276fee95aca
32 changes: 8 additions & 24 deletions test/parallel/test-http-timeout-overflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,13 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
const Countdown = require('../common/countdown');
const assert = require('assert');

const common = require('../common');
const http = require('http');
let response;

const serverReqCountdown = new Countdown(1, () => {
response.writeHead(200, { 'Content-Type': 'text/plain' });
response.end('OK');
});

const server = http.createServer(function(req, res) {
response = res;
serverReqCountdown.dec();
});

const clientReqCountdown = new Countdown(1, () => server.close());
const server = http.createServer(common.mustCall(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('OK');
}));

server.listen(0, function() {
function callback() {}
Expand All @@ -49,9 +38,9 @@ server.listen(0, function() {
}, function(res) {
req.clearTimeout(callback);

res.on('end', function() {
clientReqCountdown.dec();
});
res.on('end', common.mustCall(function() {
server.close();
}));

res.resume();
});
Expand All @@ -60,8 +49,3 @@ server.listen(0, function() {
req.setTimeout(0xffffffff, callback);
req.end();
});

process.once('exit', function() {
assert.strictEqual(clientReqCountdown.remaining, 0);
assert.strictEqual(serverReqCountdown.remaining, 0);
});