Skip to content

Commit c83b650

Browse files
James HerringtonBridgeAR
authored andcommitted
test: add tests for process.initgroups
- test argument validation - test function throws if provided group is invalid PR-URL: #24154 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0c9d86f commit c83b650

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use strict';
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
5+
if(common.isWindows||!common.isMainThread){
6+
assert.strictEqual(process.initgroups,undefined);
7+
return;
8+
}
9+
10+
[undefined,null,true,{},[],()=>{}].forEach((val)=>{
11+
assert.throws(
12+
()=>{
13+
process.initgroups(val);
14+
},
15+
{
16+
code: 'ERR_INVALID_ARG_TYPE',
17+
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
18+
message:
19+
'The "user" argument must be '+
20+
'one of type number or string. '+
21+
`Received type ${typeofval}`
22+
}
23+
);
24+
});
25+
26+
[undefined,null,true,{},[],()=>{}].forEach((val)=>{
27+
assert.throws(
28+
()=>{
29+
process.initgroups('foo',val);
30+
},
31+
{
32+
code: 'ERR_INVALID_ARG_TYPE',
33+
name: 'TypeError [ERR_INVALID_ARG_TYPE]',
34+
message:
35+
'The "extraGroup" argument must be '+
36+
'one of type number or string. '+
37+
`Received type ${typeofval}`
38+
}
39+
);
40+
});
41+
42+
assert.throws(
43+
()=>{
44+
process.initgroups(
45+
'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb',
46+
'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
47+
);
48+
},
49+
{
50+
code: 'ERR_UNKNOWN_CREDENTIAL',
51+
message:
52+
'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb'
53+
}
54+
);

0 commit comments

Comments
(0)