mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-28 08:52:45 +00:00
test: remove redundant schtasks command parsing cases
This commit is contained in:
@@ -86,74 +86,6 @@ describe("resolveTaskScriptPath", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("readScheduledTaskCommand", () => {
|
describe("readScheduledTaskCommand", () => {
|
||||||
it("parses basic command script", async () => {
|
|
||||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-schtasks-test-"));
|
|
||||||
try {
|
|
||||||
const scriptPath = path.join(tmpDir, ".openclaw", "gateway.cmd");
|
|
||||||
await fs.mkdir(path.dirname(scriptPath), { recursive: true });
|
|
||||||
await fs.writeFile(
|
|
||||||
scriptPath,
|
|
||||||
["@echo off", "node gateway.js --port 18789"].join("\r\n"),
|
|
||||||
"utf8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const env = { USERPROFILE: tmpDir, OPENCLAW_PROFILE: "default" };
|
|
||||||
const result = await readScheduledTaskCommand(env);
|
|
||||||
expect(result).toEqual({
|
|
||||||
programArguments: ["node", "gateway.js", "--port", "18789"],
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("parses script with working directory", async () => {
|
|
||||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-schtasks-test-"));
|
|
||||||
try {
|
|
||||||
const scriptPath = path.join(tmpDir, ".openclaw", "gateway.cmd");
|
|
||||||
await fs.mkdir(path.dirname(scriptPath), { recursive: true });
|
|
||||||
await fs.writeFile(
|
|
||||||
scriptPath,
|
|
||||||
["@echo off", "cd /d C:\\Projects\\openclaw", "node gateway.js"].join("\r\n"),
|
|
||||||
"utf8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const env = { USERPROFILE: tmpDir, OPENCLAW_PROFILE: "default" };
|
|
||||||
const result = await readScheduledTaskCommand(env);
|
|
||||||
expect(result).toEqual({
|
|
||||||
programArguments: ["node", "gateway.js"],
|
|
||||||
workingDirectory: "C:\\Projects\\openclaw",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("parses script with environment variables", async () => {
|
|
||||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-schtasks-test-"));
|
|
||||||
try {
|
|
||||||
const scriptPath = path.join(tmpDir, ".openclaw", "gateway.cmd");
|
|
||||||
await fs.mkdir(path.dirname(scriptPath), { recursive: true });
|
|
||||||
await fs.writeFile(
|
|
||||||
scriptPath,
|
|
||||||
["@echo off", "set NODE_ENV=production", "set PORT=18789", "node gateway.js"].join("\r\n"),
|
|
||||||
"utf8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const env = { USERPROFILE: tmpDir, OPENCLAW_PROFILE: "default" };
|
|
||||||
const result = await readScheduledTaskCommand(env);
|
|
||||||
expect(result).toEqual({
|
|
||||||
programArguments: ["node", "gateway.js"],
|
|
||||||
environment: {
|
|
||||||
NODE_ENV: "production",
|
|
||||||
PORT: "18789",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("parses script with quoted arguments containing spaces", async () => {
|
it("parses script with quoted arguments containing spaces", async () => {
|
||||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-schtasks-test-"));
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-schtasks-test-"));
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user