Skip to content

Commit d16d9cb

Browse files
Trottitaloacasas
authored andcommitted
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: nodejs#10675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent b530de4 commit d16d9cb

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

lib/cluster.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ function Worker(options) {
3131
this.exitedAfterDisconnect = undefined;
3232

3333
Object.defineProperty(this, 'suicide', {
34-
get: internalUtil.deprecate(() => {
35-
return this.exitedAfterDisconnect;
36-
}, 'worker.suicide is deprecated. ' +
37-
'Please use worker.exitedAfterDisconnect.'),
38-
set: internalUtil.deprecate((val) => {
39-
this.exitedAfterDisconnect = val;
40-
}, 'worker.suicide is deprecated. ' +
41-
'Please use worker.exitedAfterDisconnect.'),
34+
get: internalUtil.deprecate(
35+
() => this.exitedAfterDisconnect,
36+
'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.'),
37+
set: internalUtil.deprecate(
38+
(val) => { this.exitedAfterDisconnect = val; },
39+
'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.'),
4240
enumerable: true
4341
});
4442

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
require('../common');
3+
4+
const assert = require('assert');
5+
const cluster = require('cluster');
6+
7+
const worker = new cluster.Worker();
8+
9+
assert.strictEqual(worker.exitedAfterDisconnect, undefined);
10+
assert.strictEqual(worker.suicide, undefined);
11+
12+
worker.exitedAfterDisconnect = 'recommended';
13+
assert.strictEqual(worker.exitedAfterDisconnect, 'recommended');
14+
assert.strictEqual(worker.suicide, 'recommended');
15+
16+
worker.suicide = 'deprecated';
17+
assert.strictEqual(worker.exitedAfterDisconnect, 'deprecated');
18+
assert.strictEqual(worker.suicide, 'deprecated');

0 commit comments

Comments
 (0)