fix: require explicit alternate agent state

This commit is contained in:
Federico Jaramillo Martinez
2026-06-29 07:56:01 +02:00
parent 75e2377756
commit 1edebb1b04
7 changed files with 88 additions and 67 deletions
+3 -3
View File
@@ -46,7 +46,7 @@ describe("commandWithVersionCheck", () => {
it("shell-quotes command words", () => {
process.env["SHELL"] = "/bin/bash";
expect(commandWithVersionCheck("/tmp/agent's/omp")).toBe("command -v '/tmp/agent'\\''s/omp' && ('/tmp/agent'\\''s/omp' --version 2>&1 || true)");
expect(commandWithVersionCheck("/tmp/agent's/acme-agent")).toBe("command -v '/tmp/agent'\\''s/acme-agent' && ('/tmp/agent'\\''s/acme-agent' --version 2>&1 || true)");
});
});
@@ -55,11 +55,11 @@ describe("agentCommandForChecks", () => {
const dir = mkdtempSync(join(tmpdir(), "pi-web-cli-test-"));
try {
const configPath = join(dir, "config.json");
writeFileSync(configPath, `${JSON.stringify({ agent: { command: "omp" } })}\n`);
writeFileSync(configPath, `${JSON.stringify({ agent: { command: "acme-agent", dir: "/opt/acme-agent/state" } })}\n`);
process.env["PI_WEB_CONFIG"] = configPath;
delete process.env["PI_WEB_AGENT_COMMAND"];
expect(agentCommandForChecks()).toBe("omp");
expect(agentCommandForChecks()).toBe("acme-agent");
} finally {
rmSync(dir, { recursive: true, force: true });
}