sandbox-agent/foundry/packages/backend/test/keys.test.ts
2026-03-12 11:20:46 -07:00

34 lines
950 B
TypeScript

import { describe, expect, it } from "vitest";
import {
githubStateKey,
historyKey,
organizationKey,
repositoryKey,
sandboxInstanceKey,
taskKey,
taskStatusSyncKey,
userGithubDataKey,
} from "../src/actors/keys.js";
describe("actor keys", () => {
it("prefixes every key with organization namespace", () => {
const keys = [
organizationKey("default"),
repositoryKey("default", "repo"),
githubStateKey("default"),
taskKey("default", "repo", "task"),
sandboxInstanceKey("default", "daytona", "sbx"),
historyKey("default", "repo"),
taskStatusSyncKey("default", "repo", "task", "sandbox-1", "session-1"),
];
for (const key of keys) {
expect(key[0]).toBe("org");
expect(key[1]).toBe("default");
}
});
it("uses a separate namespace for user-scoped GitHub auth", () => {
expect(userGithubDataKey("user-123")).toEqual(["user", "user-123", "github"]);
});
});