Skip to content

Commit

Permalink
test: refactor code in test-cluster-http-pipe
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
edsadr authored and evanlucas committed Jan 4, 2017
1 parent 9a0711d commit ed76bfa
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/parallel/test-cluster-http-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ if (common.isWindows) {

if (cluster.isMaster) {
common.refreshTmpDir();
var worker = cluster.fork();
worker.on('message', common.mustCall(function(msg) {
assert.equal(msg, 'DONE');
const worker = cluster.fork();
worker.on('message', common.mustCall((msg) => {
assert.strictEqual(msg, 'DONE');
}));
worker.on('exit', function() {
process.exit();
});
worker.on('exit', common.mustCall(() => {}));
return;
}

http.createServer(function(req, res) {
assert.equal(req.connection.remoteAddress, undefined);
assert.equal(req.connection.localAddress, undefined); // TODO common.PIPE?
http.createServer(common.mustCall((req, res) => {
assert.strictEqual(req.connection.remoteAddress, undefined);
assert.strictEqual(req.connection.localAddress, undefined);
// TODO common.PIPE?

res.writeHead(200);
res.end('OK');
}).listen(common.PIPE, function() {
http.get({ socketPath: common.PIPE, path: '/' }, function(res) {
})).listen(common.PIPE, common.mustCall(() => {
http.get({ socketPath: common.PIPE, path: '/' }, common.mustCall((res) => {
res.resume();
res.on('end', function(err) {
if (err) throw err;
res.on('end', common.mustCall((err) => {
assert.ifError(err);
process.send('DONE');
process.exit();
});
});
});
}));
}));
}));

0 comments on commit ed76bfa

Please sign in to comment.