Skip to content

Commit

Permalink
test: add common.mustCall
Browse files Browse the repository at this point in the history
  • Loading branch information
Suixinlei committed Jul 16, 2017
1 parent 5d3609d commit 2a86f01
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions test/parallel/test-http-server-keep-alive-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ function run() {

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

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

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

test(function serverNoEndKeepAliveTimeoutWithPipeline(cb) {
let requestCount = 0;
process.on('exit', () => {
assert.strictEqual(requestCount, 3);
});
const server = https.createServer(serverOptions, (req, res) => {
requestCount++;
});
server.listen(0, common.mustCall(() => {
process.on('exit', function() {
assert.strictEqual(requestCount, 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 2a86f01

Please sign in to comment.