mirror of https://github.com/openclaw/openclaw.git
fix: tighten runtime status coverage
This commit is contained in:
parent
a54bf71b4c
commit
50c4e89aeb
|
|
@ -4,6 +4,7 @@ import { formatRuntimeStatusWithDetails } from "./runtime-status.js";
|
|||
describe("formatRuntimeStatusWithDetails", () => {
|
||||
it("falls back to unknown when status is missing", () => {
|
||||
expect(formatRuntimeStatusWithDetails({})).toBe("unknown");
|
||||
expect(formatRuntimeStatusWithDetails({ status: " " })).toBe("unknown");
|
||||
});
|
||||
|
||||
it("includes pid, distinct state, and non-empty details", () => {
|
||||
|
|
@ -26,5 +27,12 @@ describe("formatRuntimeStatusWithDetails", () => {
|
|||
details: [],
|
||||
}),
|
||||
).toBe("running");
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
status: " RUNNING ",
|
||||
state: "running",
|
||||
details: [],
|
||||
}),
|
||||
).toBe("RUNNING");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ export function formatRuntimeStatusWithDetails({
|
|||
state,
|
||||
details = [],
|
||||
}: RuntimeStatusFormatInput): string {
|
||||
const runtimeStatus = status ?? "unknown";
|
||||
const runtimeStatus = status?.trim() || "unknown";
|
||||
const fullDetails: string[] = [];
|
||||
if (pid) {
|
||||
fullDetails.push(`pid ${pid}`);
|
||||
}
|
||||
if (state && state.toLowerCase() !== runtimeStatus) {
|
||||
if (state && state.toLowerCase() !== runtimeStatus.toLowerCase()) {
|
||||
fullDetails.push(`state ${state}`);
|
||||
}
|
||||
for (const detail of details) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue