Files
paseo/packages/cli/src/utils/daemon-target.test.ts
T
Mohamed Boudra 264276880e fix(daemon): keep lifecycle operations on the selected instance
Restart reconstructed launch inputs and address fallback could redirect a home-selected shutdown to another daemon. Let supervisors publish bound endpoints, retain their worker restart contract, and share captured local lifecycle ownership between CLI and Desktop.
2026-09-09 14:09:53 +02:00

33 lines
1.3 KiB
TypeScript

import { test, expect } from "vitest";
import { selectDaemonTarget, describeDaemonTarget } from "./daemon-target.js";
test("explicit selectors win over both environment selectors", () => {
const env = { PASEO_HOME: "/tmp/a", PASEO_HOST: "unused:12345" };
expect(selectDaemonTarget({ home: "/tmp/b" }, env)).toEqual({ kind: "instance", home: "/tmp/b" });
expect(selectDaemonTarget({ host: "chosen:23456" }, env)).toEqual({
kind: "endpoint",
host: "chosen:23456",
});
expect(() => selectDaemonTarget({}, env)).toThrow();
expect(() => selectDaemonTarget({ home: "/tmp/b", host: "chosen:23456" }, {})).toThrow();
});
test("local operations ignore routing environment but reject an explicit endpoint", () => {
expect(
selectDaemonTarget({}, { PASEO_HOME: "/tmp/b", PASEO_HOST: "unused:12345" }, true),
).toEqual({ kind: "instance", home: "/tmp/b" });
expect(() => selectDaemonTarget({ host: "chosen:23456" }, {}, true)).toThrow();
});
test("endpoint descriptions redact pairing material and credentials", () => {
expect(
describeDaemonTarget({
kind: "endpoint",
host: "tcp://user:private@example.test:23456?password=secret",
}),
).not.toMatch(/private|secret/);
expect(
describeDaemonTarget({ kind: "endpoint", host: "https://app.paseo.sh/#offer=private" }),
).not.toContain("private");
});