Skip to content

Commit 842b84c

Browse files
TrottMylesBorins
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 389f294 commit 842b84c

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
@@ -1,5 +1,6 @@
11
'use strict';
22
const common = require('../common');
3+
34
const assert = require('assert');
45
const http = require('http');
56
const net = require('net');
@@ -9,16 +10,13 @@ const tests = [];
910
function test(fn) {
1011
if (!tests.length)
1112
process.nextTick(run);
12-
tests.push(fn);
13+
tests.push(common.mustCall(fn));
1314
}
1415

1516
function run() {
1617
const fn = tests.shift();
1718
if (fn) {
18-
console.log('# %s', fn.name);
1919
fn(run);
20-
} else {
21-
console.log('ok');
2220
}
2321
}
2422

@@ -27,7 +25,7 @@ test(function serverTimeout(cb) {
2725
// just do nothing, we should get a timeout event.
2826
});
2927
server.listen(common.mustCall(function() {
30-
http.get({ port: server.address().port }).on('error', common.noop);
28+
http.get({ port: server.address().port }).on('error', common.mustCall());
3129
}));
3230
const s = server.setTimeout(50, common.mustCall(function(socket) {
3331
socket.destroy();
@@ -50,7 +48,7 @@ test(function serverRequestTimeout(cb) {
5048
server.listen(common.mustCall(function() {
5149
const port = server.address().port;
5250
const req = http.request({ port: port, method: 'POST' });
53-
req.on('error', common.noop);
51+
req.on('error', common.mustCall());
5452
req.write('Hello');
5553
// req is in progress
5654
}));
@@ -68,7 +66,7 @@ test(function serverResponseTimeout(cb) {
6866
});
6967
server.listen(common.mustCall(function() {
7068
const port = server.address().port;
71-
http.get({ port: port }).on('error', common.noop);
69+
http.get({ port: port }).on('error', common.mustCall());
7270
}));
7371
});
7472

@@ -86,7 +84,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
8684
});
8785
server.listen(common.mustCall(function() {
8886
const port = server.address().port;
89-
http.get({ port: port }).on('error', common.noop);
87+
http.get({ port: port }).on('error', common.mustCall());
9088
}));
9189
});
9290

0 commit comments

Comments
 (0)