mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 20:16:53 +00:00
test: tighten runtime status and usage formatting coverage
This commit is contained in:
30
src/infra/runtime-status.test.ts
Normal file
30
src/infra/runtime-status.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatRuntimeStatusWithDetails } from "./runtime-status.js";
|
||||
|
||||
describe("formatRuntimeStatusWithDetails", () => {
|
||||
it("falls back to unknown when status is missing", () => {
|
||||
expect(formatRuntimeStatusWithDetails({})).toBe("unknown");
|
||||
});
|
||||
|
||||
it("includes pid, distinct state, and non-empty details", () => {
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
status: "running",
|
||||
pid: 1234,
|
||||
state: "sleeping",
|
||||
details: ["healthy", "", "port 18789"],
|
||||
}),
|
||||
).toBe("running (pid 1234, state sleeping, healthy, port 18789)");
|
||||
});
|
||||
|
||||
it("omits duplicate state text and falsy pid values", () => {
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
status: "running",
|
||||
pid: 0,
|
||||
state: "RUNNING",
|
||||
details: [],
|
||||
}),
|
||||
).toBe("running");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user