Skip to content

Commit 6b06c49

Browse files
edsadrMylesBorins
authored andcommitted
test: refactor code in test-cluster-http-pipe
* use common.mustCall to control the functions execution automatically * use const instead of var * use assert.strictEqual instead assert.equal * use assert.ifError instead of throw error PR-URL: #10297 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent be7917e commit 6b06c49

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/parallel/test-cluster-http-pipe.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ if (common.isWindows) {
1313

1414
if (cluster.isMaster) {
1515
common.refreshTmpDir();
16-
var worker = cluster.fork();
17-
worker.on('message', common.mustCall(function(msg) {
18-
assert.equal(msg, 'DONE');
16+
const worker = cluster.fork();
17+
worker.on('message', common.mustCall((msg) => {
18+
assert.strictEqual(msg, 'DONE');
1919
}));
20-
worker.on('exit', function() {
21-
process.exit();
22-
});
20+
worker.on('exit', common.mustCall(() => {}));
2321
return;
2422
}
2523

26-
http.createServer(function(req, res) {
27-
assert.equal(req.connection.remoteAddress, undefined);
28-
assert.equal(req.connection.localAddress, undefined); // TODO common.PIPE?
24+
http.createServer(common.mustCall((req, res) => {
25+
assert.strictEqual(req.connection.remoteAddress, undefined);
26+
assert.strictEqual(req.connection.localAddress, undefined);
27+
// TODO common.PIPE?
28+
2929
res.writeHead(200);
3030
res.end('OK');
31-
}).listen(common.PIPE, function() {
32-
http.get({ socketPath: common.PIPE, path: '/' }, function(res) {
31+
})).listen(common.PIPE, common.mustCall(() => {
32+
http.get({ socketPath: common.PIPE, path: '/' }, common.mustCall((res) => {
3333
res.resume();
34-
res.on('end', function(err) {
35-
if (err) throw err;
34+
res.on('end', common.mustCall((err) => {
35+
assert.ifError(err);
3636
process.send('DONE');
3737
process.exit();
38-
});
39-
});
40-
});
38+
}));
39+
}));
40+
}));

0 commit comments

Comments
 (0)