node/test/parallel/test-cluster-shared-handle-bind-error.js
Kevin Zurawel 228a32bfd6
test: change equal to strictEqual
This commit changes calls to `assert.equal()` to `assert.strictEqual()`.

PR-URL: https://github.com/nodejs/node/pull/9872
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-12-03 14:14:51 +01:00

27 lines
873 B
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
if (cluster.isMaster) {
// Master opens and binds the socket and shares it with the worker.
cluster.schedulingPolicy = cluster.SCHED_NONE;
// Hog the TCP port so that when the worker tries to bind, it'll fail.
net.createServer(common.fail).listen(common.PORT, function() {
var server = this;
var worker = cluster.fork();
worker.on('exit', common.mustCall(function(exitCode) {
assert.strictEqual(exitCode, 0);
server.close();
}));
});
} else {
var s = net.createServer(common.fail);
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
s.on('error', common.mustCall(function(err) {
assert.strictEqual(err.code, 'EADDRINUSE');
process.disconnect();
}));
}