mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 19:10:39 +00:00
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildSystemdUnit } from "./systemd-unit.js";
|
|
|
|
describe("buildSystemdUnit", () => {
|
|
it("quotes arguments with whitespace", () => {
|
|
const unit = buildSystemdUnit({
|
|
description: "OpenClaw Gateway",
|
|
programArguments: ["/usr/bin/openclaw", "gateway", "--name", "My Bot"],
|
|
environment: {},
|
|
});
|
|
const execStart = unit.split("\n").find((line) => line.startsWith("ExecStart="));
|
|
expect(execStart).toBe('ExecStart=/usr/bin/openclaw gateway --name "My Bot"');
|
|
});
|
|
|
|
it("renders control-group kill mode for child-process cleanup", () => {
|
|
const unit = buildSystemdUnit({
|
|
description: "OpenClaw Gateway",
|
|
programArguments: ["/usr/bin/openclaw", "gateway", "run"],
|
|
environment: {},
|
|
});
|
|
expect(unit).toContain("KillMode=control-group");
|
|
});
|
|
|
|
it("keeps restart always for supervised restarts", () => {
|
|
const unit = buildSystemdUnit({
|
|
description: "OpenClaw Gateway",
|
|
programArguments: ["/usr/bin/openclaw", "gateway", "run"],
|
|
environment: {},
|
|
});
|
|
expect(unit).toContain("Restart=always");
|
|
expect(unit).not.toContain("Restart=on-failure");
|
|
});
|
|
|
|
it("rejects environment values with line breaks", () => {
|
|
expect(() =>
|
|
buildSystemdUnit({
|
|
description: "OpenClaw Gateway",
|
|
programArguments: ["/usr/bin/openclaw", "gateway", "start"],
|
|
environment: {
|
|
INJECT: "ok\nExecStartPre=/bin/touch /tmp/oc15789_rce",
|
|
},
|
|
}),
|
|
).toThrow(/CR or LF/);
|
|
});
|
|
});
|