Skip to content

Commit

Permalink
test: refactor test-http-set-timeout-server
Browse files Browse the repository at this point in the history
* Use `common.mustCall()` to track callback invocations
* Remove console.log() statements unrelated to the test
* Add blank line to conform with test-writing guide

PR-URL: #13802
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Jun 24, 2017
1 parent b23f246 commit f1d96f0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/parallel/test-http-set-timeout-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

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

const assert = require('assert');
const http = require('http');
const net = require('net');
Expand All @@ -30,16 +31,13 @@ const tests = [];
function test(fn) {
if (!tests.length)
process.nextTick(run);
tests.push(fn);
tests.push(common.mustCall(fn));
}

function run() {
const fn = tests.shift();
if (fn) {
console.log('# %s', fn.name);
fn(run);
} else {
console.log('ok');
}
}

Expand All @@ -48,7 +46,7 @@ test(function serverTimeout(cb) {
// just do nothing, we should get a timeout event.
});
server.listen(common.mustCall(function() {
http.get({ port: server.address().port }).on('error', common.noop);
http.get({ port: server.address().port }).on('error', common.mustCall());
}));
const s = server.setTimeout(50, common.mustCall(function(socket) {
socket.destroy();
Expand All @@ -71,7 +69,7 @@ test(function serverRequestTimeout(cb) {
server.listen(common.mustCall(function() {
const port = server.address().port;
const req = http.request({ port: port, method: 'POST' });
req.on('error', common.noop);
req.on('error', common.mustCall());
req.write('Hello');
// req is in progress
}));
Expand All @@ -89,7 +87,7 @@ test(function serverResponseTimeout(cb) {
});
server.listen(common.mustCall(function() {
const port = server.address().port;
http.get({ port: port }).on('error', common.noop);
http.get({ port: port }).on('error', common.mustCall());
}));
});

Expand All @@ -107,7 +105,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
});
server.listen(common.mustCall(function() {
const port = server.address().port;
http.get({ port: port }).on('error', common.noop);
http.get({ port: port }).on('error', common.mustCall());
}));
});

Expand Down

0 comments on commit f1d96f0

Please sign in to comment.