node/test/parallel/test-process-setgroups.js
Masashi Hirano fcf059a667
test: add test unknown credential error of process.setgroups
Added test to check ERR_UNKNOWN_CREDENTIAL of process.setgroups to
increase coverage.

PR-URL: https://github.com/nodejs/node/pull/22368
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-09-03 17:56:53 +02:00

48 lines
817 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
if (common.isWindows || !common.isMainThread) {
assert.strictEqual(process.setgroups, undefined);
return;
}
assert.throws(
() => {
process.setgroups();
},
{
name: 'TypeError',
message: 'argument 1 must be an array'
}
);
assert.throws(
() => {
process.setgroups([1, -1]);
},
{
name: 'Error',
message: 'group name not found'
}
);
[undefined, null, true, {}, [], () => {}].forEach((val) => {
assert.throws(
() => {
process.setgroups([val]);
},
{
name: 'Error',
message: 'group name not found'
}
);
});
assert.throws(() => {
process.setgroups([1, 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb']);
}, {
name: 'Error',
message: 'group name not found'
});