mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
Tests should be in test/js/node/process/ not in the node parallel test directory unless copied from upstream Node.js tests.
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { isWindows } from "harness";
|
|
|
|
if (!isWindows) {
|
|
test("process.initgroups validates arguments", () => {
|
|
// Missing arguments
|
|
expect(() => {
|
|
// @ts-expect-error
|
|
process.initgroups();
|
|
}).toThrow();
|
|
|
|
expect(() => {
|
|
// @ts-expect-error
|
|
process.initgroups("user");
|
|
}).toThrow();
|
|
|
|
// Invalid argument types
|
|
const invalidValues = [null, true, {}, [], () => {}];
|
|
|
|
for (const val of invalidValues) {
|
|
expect(() => {
|
|
// @ts-expect-error
|
|
process.initgroups(val, 1000);
|
|
}).toThrow();
|
|
|
|
expect(() => {
|
|
// @ts-expect-error
|
|
process.initgroups("user", val);
|
|
}).toThrow();
|
|
}
|
|
});
|
|
|
|
test("process.initgroups throws for non-existent user", () => {
|
|
expect(() => {
|
|
process.initgroups("fhqwhgadshgnsdhjsdbkhsdabkfabkveyb", 1000);
|
|
}).toThrow(/User identifier does not exist/);
|
|
});
|
|
|
|
test("process.initgroups throws for non-existent group", () => {
|
|
expect(() => {
|
|
process.initgroups("root", "fhqwhgadshgnsdhjsdbkhsdabkfabkveyb");
|
|
}).toThrow(/Group identifier does not exist/);
|
|
});
|
|
|
|
test("process.initgroups throws for invalid uid", () => {
|
|
expect(() => {
|
|
process.initgroups(9999999, 1000);
|
|
}).toThrow(/User identifier does not exist/);
|
|
});
|
|
} else {
|
|
test("process.initgroups is undefined on Windows", () => {
|
|
expect(process.initgroups).toBeUndefined();
|
|
});
|
|
}
|