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‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

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

3637
functionrun(){
3738
constfn=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
consts=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
constport=server.address().port;
7371
constreq=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
constport=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
constport=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)