Refactor plugin architecture, isolate Windows-spefic code
This commit is contained in:
33
tests/process/PosixProcess.test.ts
Normal file
33
tests/process/PosixProcess.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { PosixProcess } from "../../src/server/process/PosixProcess";
|
||||
|
||||
describe.skipIf(process.platform === "win32")("PosixProcess", () => {
|
||||
const processImpl = new PosixProcess();
|
||||
|
||||
describe("verifyCommand", () => {
|
||||
test("returns null for non-absolute commands", async () => {
|
||||
// Non-absolute paths should return null (let spawn handle it)
|
||||
const result = await processImpl.verifyCommand("ls");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test("returns null for existing absolute path", async () => {
|
||||
// /bin/ls should exist on most POSIX systems
|
||||
const result = await processImpl.verifyCommand("/bin/ls");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test("returns error message for non-existent absolute path", async () => {
|
||||
const nonExistentPath = "/nonexistent/path/to/executable";
|
||||
const result = await processImpl.verifyCommand(nonExistentPath);
|
||||
expect(result).toContain("Executable not found");
|
||||
expect(result).toContain(nonExistentPath);
|
||||
});
|
||||
|
||||
test("returns error for non-executable file", async () => {
|
||||
// Test with a regular file that's not executable
|
||||
const result = await processImpl.verifyCommand("/etc/passwd");
|
||||
expect(result).toContain("Executable not found");
|
||||
});
|
||||
});
|
||||
});
|
||||
26
tests/process/WindowsProcess.test.ts
Normal file
26
tests/process/WindowsProcess.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { WindowsProcess } from "../../src/server/process/WindowsProcess";
|
||||
|
||||
describe.skipIf(process.platform !== "win32")("WindowsProcess", () => {
|
||||
const processImpl = new WindowsProcess();
|
||||
|
||||
describe("verifyCommand", () => {
|
||||
test("returns null for existing executable in PATH", async () => {
|
||||
// 'cmd' should exist on all Windows systems
|
||||
const result = await processImpl.verifyCommand("cmd");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test("returns error message for non-existent executable", async () => {
|
||||
const nonExistentPath = "C:\\nonexistent\\path\\to\\executable.exe";
|
||||
const result = await processImpl.verifyCommand(nonExistentPath);
|
||||
expect(result).toContain("Executable not found");
|
||||
expect(result).toContain(nonExistentPath);
|
||||
});
|
||||
|
||||
test("returns error for non-existent command in PATH", async () => {
|
||||
const result = await processImpl.verifyCommand("definitely-not-a-real-command-12345");
|
||||
expect(result).toContain("Executable not found");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user