mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
test: add session name sanitization when fetching worktrees
This commit is contained in:
@@ -681,6 +681,22 @@ describe("core utils", () => {
|
||||
expect(worktrees[0]?.branch).toBe("opencode/my-session/gpt-5.2");
|
||||
});
|
||||
|
||||
test("sanitizes session name when filtering worktrees", async () => {
|
||||
spyOn(os, "homedir").mockReturnValue("/home/user");
|
||||
// The worktree path uses the sanitized version "my-session"
|
||||
mockCommandResponses["git worktree list --porcelain"] = {
|
||||
ok: true,
|
||||
stdout: "worktree /home/user/.local/share/opencode/multi-model/my-session/gpt-5.2\nbranch refs/heads/opencode/my-session/gpt-5.2",
|
||||
stderr: "",
|
||||
};
|
||||
|
||||
// Pass unsanitized session name with spaces and special chars
|
||||
const worktrees = await getWorktreesForSession("my session!");
|
||||
// Should still find the worktree because it sanitizes internally
|
||||
expect(worktrees.length).toBe(1);
|
||||
expect(worktrees[0]?.path).toBe("/home/user/.local/share/opencode/multi-model/my-session/gpt-5.2");
|
||||
});
|
||||
|
||||
test("returns empty array when no matching worktrees", async () => {
|
||||
spyOn(os, "homedir").mockReturnValue("/home/user");
|
||||
mockCommandResponses["git worktree list --porcelain"] = {
|
||||
|
||||
Reference in New Issue
Block a user