rollbridge 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ // @ts-check
2
+
3
+ import assert from "node:assert/strict"
4
+ import test from "node:test"
5
+ import {resolveGroupId, resolveUserId} from "../src/system-ids.js"
6
+
7
+ const linuxOnly = process.platform !== "linux" && "requires /etc/passwd and /etc/group (Linux)"
8
+
9
+ test("resolves numeric ids and numeric strings as-is", () => {
10
+ assert.equal(resolveUserId(1000), 1000)
11
+ assert.equal(resolveUserId("1000"), 1000)
12
+ assert.equal(resolveGroupId(0), 0)
13
+ assert.equal(resolveGroupId("42"), 42)
14
+ })
15
+
16
+ test("resolves user and group names to ids", {skip: linuxOnly}, () => {
17
+ assert.equal(resolveUserId("root"), 0)
18
+ assert.equal(resolveGroupId("root"), 0)
19
+ })
20
+
21
+ test("throws for an unknown user or group name", {skip: linuxOnly}, () => {
22
+ assert.throws(() => resolveUserId("rollbridge-no-such-user"), /Unknown user "rollbridge-no-such-user"/)
23
+ assert.throws(() => resolveGroupId("rollbridge-no-such-group"), /Unknown group "rollbridge-no-such-group"/)
24
+ })