Skip to content

Commit f1d96f0

Browse files
Trottaddaleax
authored andcommitted
test: refactor test-http-set-timeout-server
* 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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent b23f246 commit f1d96f0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/parallel/test-http-set-timeout-server.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
'use strict';
2323
const common = require('../common');
24+
2425
const assert = require('assert');
2526
const http = require('http');
2627
const net = require('net');
@@ -30,16 +31,13 @@ const tests = [];
3031
function test(fn) {
3132
if (!tests.length)
3233
process.nextTick(run);
33-
tests.push(fn);
34+
tests.push(common.mustCall(fn));
3435
}
3536

3637
function run() {
3738
const fn = tests.shift();
3839
if (fn) {
39-
console.log('# %s', fn.name);
4040
fn(run);
41-
} else {
42-
console.log('ok');
4341
}
4442
}
4543

@@ -48,7 +46,7 @@ test(function serverTimeout(cb) {
4846
// just do nothing, we should get a timeout event.
4947
});
5048
server.listen(common.mustCall(function() {
51-
http.get({ port: server.address().port }).on('error', common.noop);
49+
http.get({ port: server.address().port }).on('error', common.mustCall());
5250
}));
5351
const s = server.setTimeout(50, common.mustCall(function(socket) {
5452
socket.destroy();
@@ -71,7 +69,7 @@ test(function serverRequestTimeout(cb) {
7169
server.listen(common.mustCall(function() {
7270
const port = server.address().port;
7371
const req = http.request({ port: port, method: 'POST' });
74-
req.on('error', common.noop);
72+
req.on('error', common.mustCall());
7573
req.write('Hello');
7674
// req is in progress
7775
}));
@@ -89,7 +87,7 @@ test(function serverResponseTimeout(cb) {
8987
});
9088
server.listen(common.mustCall(function() {
9189
const port = server.address().port;
92-
http.get({ port: port }).on('error', common.noop);
90+
http.get({ port: port }).on('error', common.mustCall());
9391
}));
9492
});
9593

@@ -107,7 +105,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
107105
});
108106
server.listen(common.mustCall(function() {
109107
const port = server.address().port;
110-
http.get({ port: port }).on('error', common.noop);
108+
http.get({ port: port }).on('error', common.mustCall());
111109
}));
112110
});
113111

0 commit comments

Comments
 (0)