1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4 5if (common.isWindows) { 6 assert.strictEqual(process.setgroups, undefined); 7 return; 8} 9 10if (!common.isMainThread) 11 return; 12 13assert.throws( 14 () => { 15 process.setgroups(); 16 }, 17 { 18 code: 'ERR_INVALID_ARG_TYPE', 19 name: 'TypeError', 20 message: 'The "groups" argument must be an instance of Array. ' + 21 'Received undefined' 22 } 23); 24 25assert.throws( 26 () => { 27 process.setgroups([1, -1]); 28 }, 29 { 30 code: 'ERR_OUT_OF_RANGE', 31 name: 'RangeError', 32 message: 'The value of "groups[1]" is out of range. ' + 33 'It must be >= 0 && < 4294967296. Received -1' 34 } 35); 36 37[undefined, null, true, {}, [], () => {}].forEach((val) => { 38 assert.throws( 39 () => { 40 process.setgroups([val]); 41 }, 42 { 43 code: 'ERR_INVALID_ARG_TYPE', 44 name: 'TypeError', 45 message: 'The "groups[0]" argument must be ' + 46 'one of type number or string.' + 47 common.invalidArgTypeHelper(val) 48 } 49 ); 50}); 51 52assert.throws(() => { 53 process.setgroups([1, 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb']); 54}, { 55 code: 'ERR_UNKNOWN_CREDENTIAL', 56 message: 'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb' 57}); 58