Allow restarting failed server instances

This commit is contained in:
npc0-hue
2026-08-06 18:18:20 +08:00
parent 1915565385
commit acec5e4367
4 changed files with 38 additions and 1 deletions
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { canStartServer, canStopServer } from "./serverManagement";
import type { ServerInstanceState } from "../api/types";
describe("server management lifecycle contracts", () => {
it("allows explicit starts from recoverable non-running states", () => {
const startable: ServerInstanceState[] = ["ready", "stopped", "failed"];
const blocked: ServerInstanceState[] = ["draft", "installing", "running", "deleted"];
expect(startable.every(canStartServer)).toBe(true);
expect(blocked.some(canStartServer)).toBe(false);
});
it("keeps stop limited to running servers", () => {
expect(canStopServer("running")).toBe(true);
expect(canStopServer("failed")).toBe(false);
});
});