diff options
author | cjihrig <cjihrig@gmail.com> | 2019-07-01 17:38:08 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-07-03 17:54:07 +0300 |
commit | 492037ab801391b0a86d1cc1204a5f14d5b74641 (patch) | |
tree | 0d32871093024c031fb7662b197efed5cf875404 | |
parent | fcf8fe9f1a556758eb9faf86bf74de2ddda805c8 (diff) |
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: https://github.com/nodejs/node/pull/28498
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
-rw-r--r-- | test/parallel/test-resource-usage.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/parallel/test-resource-usage.js b/test/parallel/test-resource-usage.js index 25302b8413f..ff41452f4a7 100644 --- a/test/parallel/test-resource-usage.js +++ b/test/parallel/test-resource-usage.js @@ -3,8 +3,7 @@ require('../common'); const assert = require('assert'); const rusage = process.resourceUsage(); - -[ +const fields = [ 'userCPUTime', 'systemCPUTime', 'maxRSS', @@ -21,7 +20,11 @@ const rusage = process.resourceUsage(); 'signalsCount', 'voluntaryContextSwitches', 'involuntaryContextSwitches' -].forEach((n) => { +]; + +assert.deepStrictEqual(Object.keys(rusage).sort(), fields.sort()); + +fields.forEach((n) => { assert.strictEqual(typeof rusage[n], 'number', `${n} should be a number`); assert(rusage[n] >= 0, `${n} should be above or equal 0`); }); |