Files
diegosouzapw--omniroute/tests/unit/copilot-runOmniRouteCli.test.ts
2026-07-13 13:39:12 +08:00

36 lines
1.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
test("runOmniRouteCli: missing command returns error", async () => {
const { getCopilotTool } = await import("../../src/lib/copilot/tools.ts");
const tool = getCopilotTool("runOmniRouteCli");
assert.ok(tool);
const result = await tool.handler({});
assert.equal(result, "Please provide a command to execute.");
});
test("runOmniRouteCli: empty command returns error", async () => {
const { getCopilotTool } = await import("../../src/lib/copilot/tools.ts");
const tool = getCopilotTool("runOmniRouteCli");
assert.ok(tool);
const result = await tool.handler({ command: "" });
assert.equal(result, "Please provide a command to execute.");
});
test("runOmniRouteCli: returns CLI-not-found when omniroute unavailable", async () => {
const { getCopilotTool } = await import("../../src/lib/copilot/tools.ts");
const tool = getCopilotTool("runOmniRouteCli");
assert.ok(tool);
const originalPath = process.env.PATH;
try {
process.env.PATH = "";
const result = await tool.handler({ command: "health" });
assert.ok(
result.includes("omniroute CLI not found in PATH"),
`Expected CLI-not-found message, got: ${result}`
);
} finally {
process.env.PATH = originalPath;
}
});