serviceInstallation.test.ts 1021 B

12345678910111213141516171819202122
  1. import { join } from "node:path";
  2. import { describe, expect, it } from "vitest";
  3. import { createServiceDescriptor } from "../src/platform/serviceManager.js";
  4. import { serviceDescriptorBelongsToRoot } from "../src/runtime/serviceInstallation.js";
  5. describe("service installation compatibility", () => {
  6. it.each(["darwin", "linux", "win32"] as const)(
  7. "only matches a legacy %s descriptor owned by the same server root",
  8. (platform) => {
  9. const firstRoot = "/var/lib/zcode-first/.zcode/server";
  10. const secondRoot = "/var/lib/zcode-second/.zcode/server";
  11. const descriptor = createServiceDescriptor({
  12. platform,
  13. command: join(firstRoot, "bin", platform === "win32" ? "zcode.cmd" : "zcode"),
  14. args: ["serve", "--supervisor", "--server-root", firstRoot],
  15. });
  16. expect(serviceDescriptorBelongsToRoot(descriptor.content, platform, firstRoot)).toBe(true);
  17. expect(serviceDescriptorBelongsToRoot(descriptor.content, platform, secondRoot)).toBe(false);
  18. },
  19. );
  20. });