fix: recover run runtime state and logs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { canStartServer, canStopServer } from "./serverManagement";
|
||||
import type { ServerInstanceState } from "../api/types";
|
||||
import { canStartServer, canStopServer, runtimeObservationFreshness } from "./serverManagement";
|
||||
import type { RunEndpointResponse, ServerInstanceResponse, ServerInstanceState } from "../api/types";
|
||||
|
||||
describe("server management lifecycle contracts", () => {
|
||||
it("allows explicit starts from recoverable non-running states", () => {
|
||||
@@ -16,4 +16,12 @@ describe("server management lifecycle contracts", () => {
|
||||
expect(canStopServer("running")).toBe(true);
|
||||
expect(canStopServer("failed")).toBe(false);
|
||||
});
|
||||
|
||||
it("distinguishes a fresh Run observation from an unverified historical lifecycle state", () => {
|
||||
const instance = { id: "server-1", state: "running", runEndpointId: "run-1" } as ServerInstanceResponse;
|
||||
const endpoint = { id: "run-1", status: "online", lastHeartbeatAt: "2026-08-07T10:00:00Z" } as RunEndpointResponse;
|
||||
expect(runtimeObservationFreshness(instance, endpoint, Date.parse("2026-08-07T10:00:30Z"))).toBe("fresh");
|
||||
expect(runtimeObservationFreshness(instance, endpoint, Date.parse("2026-08-07T10:01:00Z"))).toBe("unverified");
|
||||
expect(runtimeObservationFreshness(instance, { ...endpoint, status: "offline" }, Date.parse("2026-08-07T10:00:01Z"))).toBe("unverified");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user