serverIdentity.test.ts 1.1 KB

1234567891011121314151617181920212223
  1. import { mkdtemp } from "node:fs/promises";
  2. import { join } from "node:path";
  3. import { tmpdir } from "node:os";
  4. import { describe, expect, it } from "vitest";
  5. import { resolveServerLayout } from "../src/runtime/paths.js";
  6. import { ReleaseManager } from "../src/runtime/releaseManager.js";
  7. import { resolveCoreServerId } from "../src/server-core/serverIdentity.js";
  8. import { validateServerInstallOwnership } from "../src/runtime/installationOwnership.js";
  9. describe("Server Core identity", () => {
  10. it("uses the persisted installation id from the ownership marker", async () => {
  11. const root = await mkdtemp(join(tmpdir(), "zcode-server-identity-"));
  12. const layout = resolveServerLayout(join(root, "server"));
  13. await new ReleaseManager(layout).ensure();
  14. const ownership = await validateServerInstallOwnership(layout);
  15. await expect(resolveCoreServerId(layout.serverRoot)).resolves.toBe(ownership.installationId);
  16. });
  17. it("leaves direct HTTP factory callers without a server root compatible", async () => {
  18. await expect(resolveCoreServerId()).resolves.toBeUndefined();
  19. });
  20. });