Browse Source

test,cluster: add test-cluster-worker-deprecated

Add test to cover setter for deprecated cluster Worker property.
Previously, the setter was not being exercised in tests.

PR-URL: https://github.com/nodejs/node/pull/10675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
v7.x
Rich Trott 8 years ago
committed by Italo A. Casas
parent
commit
4323c8018e
  1. 14
      lib/cluster.js
  2. 18
      test/parallel/test-cluster-worker-deprecated.js

14
lib/cluster.js

@ -31,14 +31,12 @@ function Worker(options) {
this.exitedAfterDisconnect = undefined;
Object.defineProperty(this, 'suicide', {
get: internalUtil.deprecate(() => {
return this.exitedAfterDisconnect;
}, 'worker.suicide is deprecated. ' +
'Please use worker.exitedAfterDisconnect.'),
set: internalUtil.deprecate((val) => {
this.exitedAfterDisconnect = val;
}, 'worker.suicide is deprecated. ' +
'Please use worker.exitedAfterDisconnect.'),
get: internalUtil.deprecate(
() => this.exitedAfterDisconnect,
'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.'),
set: internalUtil.deprecate(
(val) => { this.exitedAfterDisconnect = val; },
'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.'),
enumerable: true
});

18
test/parallel/test-cluster-worker-deprecated.js

@ -0,0 +1,18 @@
'use strict';
require('../common');
const assert = require('assert');
const cluster = require('cluster');
const worker = new cluster.Worker();
assert.strictEqual(worker.exitedAfterDisconnect, undefined);
assert.strictEqual(worker.suicide, undefined);
worker.exitedAfterDisconnect = 'recommended';
assert.strictEqual(worker.exitedAfterDisconnect, 'recommended');
assert.strictEqual(worker.suicide, 'recommended');
worker.suicide = 'deprecated';
assert.strictEqual(worker.exitedAfterDisconnect, 'deprecated');
assert.strictEqual(worker.suicide, 'deprecated');
Loading…
Cancel
Save