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 <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 389f294 commit 842b84c

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
constcommon=require('../common');
3+
34
constassert=require('assert');
45
consthttp=require('http');
56
constnet=require('net');
@@ -9,16 +10,13 @@ const tests = [];
910
functiontest(fn){
1011
if(!tests.length)
1112
process.nextTick(run);
12-
tests.push(fn);
13+
tests.push(common.mustCall(fn));
1314
}
1415

1516
functionrun(){
1617
constfn=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
consts=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
constport=server.address().port;
5250
constreq=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
constport=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
constport=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)