mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
Prevent duplicate agent shortnames per company
This commit is contained in:
parent
e670324334
commit
192d76678e
2 changed files with 97 additions and 0 deletions
37
server/src/__tests__/agent-shortname-collision.test.ts
Normal file
37
server/src/__tests__/agent-shortname-collision.test.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { hasAgentShortnameCollision } from "../services/agents.ts";
|
||||
|
||||
describe("hasAgentShortnameCollision", () => {
|
||||
it("detects collisions by normalized shortname", () => {
|
||||
const collision = hasAgentShortnameCollision("Codex Coder", [
|
||||
{ id: "a1", name: "codex-coder", status: "idle" },
|
||||
]);
|
||||
expect(collision).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores terminated agents", () => {
|
||||
const collision = hasAgentShortnameCollision("Codex Coder", [
|
||||
{ id: "a1", name: "codex-coder", status: "terminated" },
|
||||
]);
|
||||
expect(collision).toBe(false);
|
||||
});
|
||||
|
||||
it("ignores the excluded agent id", () => {
|
||||
const collision = hasAgentShortnameCollision(
|
||||
"Codex Coder",
|
||||
[
|
||||
{ id: "a1", name: "codex-coder", status: "idle" },
|
||||
{ id: "a2", name: "other-agent", status: "idle" },
|
||||
],
|
||||
{ excludeAgentId: "a1" },
|
||||
);
|
||||
expect(collision).toBe(false);
|
||||
});
|
||||
|
||||
it("does not collide when candidate has no shortname", () => {
|
||||
const collision = hasAgentShortnameCollision("!!!", [
|
||||
{ id: "a1", name: "codex-coder", status: "idle" },
|
||||
]);
|
||||
expect(collision).toBe(false);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue