mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat: vendor permission system source
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createPermissionRequestId } from "#src/permission-request-id";
|
||||
|
||||
describe("createPermissionRequestId", () => {
|
||||
it("prefixes the id so it is distinguishable from an SDK tool call id", () => {
|
||||
expect(createPermissionRequestId()).toMatch(
|
||||
/^perm-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,
|
||||
);
|
||||
});
|
||||
|
||||
it("mints a distinct id on every call", () => {
|
||||
const ids = new Set(
|
||||
Array.from({ length: 100 }, () => createPermissionRequestId()),
|
||||
);
|
||||
expect(ids.size).toBe(100);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user