Skip to content

Commit 9a5811f

Browse files
committed
🤖 test: make server lockfile failure deterministic
The lockfile-acquisition failure test relied on chmod-based permission errors, which can be unreliable in CI (e.g. privileged runners). Simulate failure by passing a muxHome path that is a file (not a directory), which triggers ENOTDIR after server startup.
1 parent d25724d commit 9a5811f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/node/services/serverService.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,19 @@ describe("ServerService.startServer", () => {
7777
}
7878

7979
test("cleans up server when lockfile acquisition fails", async () => {
80-
// Skip on Windows where chmod doesn't work the same way
81-
if (process.platform === "win32") {
82-
return;
83-
}
84-
8580
const service = new ServerService();
8681

87-
// Make muxHome read-only so lockfile.acquire() will fail
88-
await fs.chmod(tempDir, 0o444);
82+
// Use a muxHome path that is a FILE (not a directory) so lockfile.acquire() fails
83+
// after the server has started.
84+
const muxHome = path.join(tempDir, "not-a-dir");
85+
await fs.writeFile(muxHome, "not a directory");
8986

9087
let thrownError: Error | null = null;
9188

9289
try {
9390
// Start server - this should fail when trying to write lockfile
9491
await service.startServer({
95-
muxHome: tempDir,
92+
muxHome,
9693
context: stubContext as ORPCContext,
9794
authToken: "test-token",
9895
port: 0, // random port
@@ -103,7 +100,7 @@ describe("ServerService.startServer", () => {
103100

104101
// Verify that an error was thrown
105102
expect(thrownError).not.toBeNull();
106-
expect(thrownError!.message).toMatch(/EACCES|permission denied/i);
103+
expect(thrownError!.message).toMatch(/ENOTDIR|not a directory|EACCES|permission denied/i);
107104

108105
// Verify the server is NOT left running
109106
expect(service.isServerRunning()).toBe(false);

0 commit comments

Comments
 (0)