






















@@ -1,3 +1,6 @@
1+import fs from "node:fs";
2+import os from "node:os";
3+import path from "node:path";
14import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
2536const mocks = vi.hoisted(() => ({
@@ -11,10 +14,12 @@ vi.mock("./io.js", () => ({
1114}));
12151316let formatConfigPath: typeof import("./logging.js").formatConfigPath;
17+let formatConfigUpdatedMessage: typeof import("./logging.js").formatConfigUpdatedMessage;
1418let logConfigUpdated: typeof import("./logging.js").logConfigUpdated;
15191620beforeAll(async () => {
17-({ formatConfigPath, logConfigUpdated } = await import("./logging.js"));
21+({ formatConfigPath, formatConfigUpdatedMessage, logConfigUpdated } =
22+await import("./logging.js"));
1823});
19242025beforeEach(() => {
@@ -29,6 +34,19 @@ describe("config logging", () => {
2934it("logs the live config path when no explicit path is provided", () => {
3035const runtime = { log: vi.fn() };
3136logConfigUpdated(runtime as never);
32-expect(runtime.log).toHaveBeenCalledWith("Updated /tmp/openclaw-dev/openclaw.json");
37+expect(runtime.log).toHaveBeenCalledWith("Updated config: /tmp/openclaw-dev/openclaw.json");
38+});
39+40+it("formats backup as an indented detail when present", () => {
41+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-config-log-"));
42+const configPath = path.join(dir, "openclaw.json");
43+const backupPath = `${configPath}.bak`;
44+fs.writeFileSync(backupPath, "{}", "utf8");
45+46+expect(
47+formatConfigUpdatedMessage(configPath, {
48+ backupPath,
49+}),
50+).toBe(`Updated config: ${configPath}\n Backup: ${backupPath}`);
3351});
3452});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。