Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests for process.initgroups #24154

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions test/parallel/test-process-initgroups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';
const common = require('../common');
const assert = require('assert');

if (common.isWindows || !common.isMainThread) {
assert.strictEqual(process.initgroups, undefined);
return;
}

[undefined, null, true, {}, [], () => {}].forEach((val) => {
assert.throws(
() => {
process.initgroups(val);
},
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
message:
'The "user" argument must be ' +
'one of type number or string. ' +
`Received type ${typeof val}`
}
);
});

[undefined, null, true, {}, [], () => {}].forEach((val) => {
assert.throws(
() => {
process.initgroups('foo', val);
},
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
message:
'The "extraGroup" argument must be ' +
'one of type number or string. ' +
`Received type ${typeof val}`
}
);
});

assert.throws(
() => {
process.initgroups(
'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb',
'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
);
},
{
code: 'ERR_UNKNOWN_CREDENTIAL',
message:
'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
}
);