Allow restarting failed server instances
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -108,7 +108,7 @@ export function endpointLabel(endpoint: RunEndpointResponse | undefined, runEndp
|
||||
}
|
||||
|
||||
export function canStartServer(state: ServerInstanceState): boolean {
|
||||
return state === "ready" || state === "stopped";
|
||||
return state === "ready" || state === "stopped" || state === "failed";
|
||||
}
|
||||
|
||||
export function canStopServer(state: ServerInstanceState): boolean {
|
||||
|
||||
Reference in New Issue
Block a user