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 } 33); 34 35[undefined, null, true, {}, [], () => {}].forEach((val) => { 36 assert.throws( 37 () => { 38 process.setgroups([val]); 39 }, 40 { 41 code: 'ERR_INVALID_ARG_TYPE', 42 name: 'TypeError', 43 message: 'The "groups[0]" argument must be ' + 44 'one of type number or string.' + 45 common.invalidArgTypeHelper(val) 46 } 47 ); 48}); 49 50assert.throws(() => { 51 process.setgroups([1, 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb']); 52}, { 53 code: 'ERR_UNKNOWN_CREDENTIAL', 54 message: 'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb' 55}); 56