Skip to content

Commit e4f1e90

Browse files
cjihrigtargos
authored andcommitted
test: increase test-resource-usage.js validation
This commit adds an assertion checking the exact field names returned by process.resourceUsage(). This ensures that no new fields accidentally slip into the returned object in the future. PR-URL: #28498 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent f3f51e4 commit e4f1e90

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/parallel/test-resource-usage.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ require('../common');
33
const assert = require('assert');
44

55
const rusage = process.resourceUsage();
6-
7-
[
6+
const fields = [
87
'userCPUTime',
98
'systemCPUTime',
109
'maxRSS',
@@ -21,7 +20,11 @@ const rusage = process.resourceUsage();
2120
'signalsCount',
2221
'voluntaryContextSwitches',
2322
'involuntaryContextSwitches'
24-
].forEach((n) => {
23+
];
24+
25+
assert.deepStrictEqual(Object.keys(rusage).sort(), fields.sort());
26+
27+
fields.forEach((n) => {
2528
assert.strictEqual(typeof rusage[n], 'number', `${n} should be a number`);
2629
assert(rusage[n] >= 0, `${n} should be above or equal 0`);
2730
});

0 commit comments

Comments
 (0)