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", () => {
|
describe("formatRuntimeStatusWithDetails", () => {
|
||||||
it("falls back to unknown when status is missing", () => {
|
it("falls back to unknown when status is missing", () => {
|
||||||
expect(formatRuntimeStatusWithDetails({})).toBe("unknown");
|
expect(formatRuntimeStatusWithDetails({})).toBe("unknown");
|
||||||
|
expect(formatRuntimeStatusWithDetails({ status: " " })).toBe("unknown");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes pid, distinct state, and non-empty details", () => {
|
it("includes pid, distinct state, and non-empty details", () => {
|
||||||
|
|
@ -26,5 +27,12 @@ describe("formatRuntimeStatusWithDetails", () => {
|
||||||
details: [],
|
details: [],
|
||||||
}),
|
}),
|
||||||
).toBe("running");
|
).toBe("running");
|
||||||
|
expect(
|
||||||
|
formatRuntimeStatusWithDetails({
|
||||||
|
status: " RUNNING ",
|
||||||
|
state: "running",
|
||||||
|
details: [],
|
||||||
|
}),
|
||||||
|
).toBe("RUNNING");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@ export function formatRuntimeStatusWithDetails({
|
||||||
state,
|
state,
|
||||||
details = [],
|
details = [],
|
||||||
}: RuntimeStatusFormatInput): string {
|
}: RuntimeStatusFormatInput): string {
|
||||||
const runtimeStatus = status ?? "unknown";
|
const runtimeStatus = status?.trim() || "unknown";
|
||||||
const fullDetails: string[] = [];
|
const fullDetails: string[] = [];
|
||||||
if (pid) {
|
if (pid) {
|
||||||
fullDetails.push(`pid ${pid}`);
|
fullDetails.push(`pid ${pid}`);
|
||||||
}
|
}
|
||||||
if (state && state.toLowerCase() !== runtimeStatus) {
|
if (state && state.toLowerCase() !== runtimeStatus.toLowerCase()) {
|
||||||
fullDetails.push(`state ${state}`);
|
fullDetails.push(`state ${state}`);
|
||||||
}
|
}
|
||||||
for (const detail of details) {
|
for (const detail of details) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue