Skip to content

Commit

Permalink
test: remove exit handler & add common.mustCall
Browse files Browse the repository at this point in the history
  • Loading branch information
Suixinlei committed Jul 16, 2017
1 parent 2a86f01 commit 3a86bee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
22 changes: 3 additions & 19 deletions test/parallel/test-http-server-keep-alive-timeout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');

Expand All @@ -20,16 +19,9 @@ function run() {
}

test(function serverEndKeepAliveTimeoutWithPipeline(cb) {
let requestCount = 0;
const server = http.createServer((req, res) => {
requestCount++;
const server = http.createServer(common.mustCall((req, res) => {
res.end();
});
server.listen(0, common.mustCall(() => {
process.on('exit', () => {
assert.strictEqual(requestCount, 3);
});
}));
}, 3));
server.setTimeout(500, common.mustCall((socket) => {
// End this test and call `run()` for the next test (if any).
socket.destroy();
Expand All @@ -51,15 +43,7 @@ test(function serverEndKeepAliveTimeoutWithPipeline(cb) {
});

test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
let requestCount = 0;
const server = http.createServer((req, res) => {
requestCount++;
});
server.listen(0, common.mustCall(() => {
process.on('exit', () => {
assert.strictEqual(requestCount, 3);
});
}));
const server = http.createServer(common.mustCall((req, res) => {}, 3));
server.setTimeout(500, common.mustCall((socket) => {
// End this test and call `run()` for the next test (if any).
socket.destroy();
Expand Down
28 changes: 8 additions & 20 deletions test/parallel/test-https-server-keep-alive-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const https = require('https');
const tls = require('tls');
const fs = require('fs');
Expand All @@ -29,16 +28,11 @@ function run() {
}

test(function serverKeepAliveTimeoutWithPipeline(cb) {
let requestCount = 0;
const server = https.createServer(serverOptions, (req, res) => {
requestCount++;
res.end();
});
server.listen(0, common.mustCall(() => {
process.on('exit', function() {
assert.strictEqual(requestCount, 3);
});
}));
const server = https.createServer(
serverOptions,
common.mustCall((req, res) => {
res.end();
}, 3));
server.setTimeout(500, common.mustCall((socket) => {
// End this test and call `run()` for the next test (if any).
socket.destroy();
Expand All @@ -61,15 +55,9 @@ test(function serverKeepAliveTimeoutWithPipeline(cb) {
});

test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
let requestCount = 0;
const server = https.createServer(serverOptions, (req, res) => {
requestCount++;
});
server.listen(0, common.mustCall(() => {
process.on('exit', function() {
assert.strictEqual(requestCount, 3);
});
}));
const server = https.createServer(
serverOptions,
common.mustCall((req, res) => {}, 3));
server.setTimeout(500, common.mustCall((socket) => {
// End this test and call `run()` for the next test (if any).
socket.destroy();
Expand Down

0 comments on commit 3a86bee

Please sign in to comment.