workspace.test.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import { describe, expect, it } from "vitest";
  2. import { resolveWorkspaceRefFromId } from "../src/zcode-protocol/workspace.js";
  3. describe("resolveWorkspaceRefFromId", () => {
  4. it("带显式 user 的 WSL identity 还原真实 working directory", () => {
  5. const workspaceIdentity = "remote:wsl:Ubuntu-24.04:dev:/home/dev/coding/DEMO-ERP-NEW";
  6. expect(resolveWorkspaceRefFromId(workspaceIdentity)).toEqual({
  7. workspaceIdentity,
  8. workspaceKey: workspaceIdentity,
  9. workspacePath: "/home/dev/coding/DEMO-ERP-NEW",
  10. });
  11. });
  12. it("本地 workspacePath 保持 fallback 语义", () => {
  13. expect(resolveWorkspaceRefFromId("/Users/dev/workspace")).toEqual({
  14. workspaceIdentity: undefined,
  15. workspaceKey: "/Users/dev/workspace",
  16. workspacePath: "/Users/dev/workspace",
  17. });
  18. });
  19. it("非法 remote identity 不得回退为本地路径", () => {
  20. expect(() => resolveWorkspaceRefFromId("remote:wsl:Ubuntu-24.04")).toThrow(
  21. "Invalid remote workspace identity",
  22. );
  23. });
  24. });