mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 10:20:34 +00:00
refactor: dedupe core config and runtime helpers
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { withTempHome } from "../../test/helpers/temp-home.js";
|
||||
import { runDoctorConfigWithInput } from "./doctor-config-flow.test-utils.js";
|
||||
|
||||
const { noteSpy } = vi.hoisted(() => ({
|
||||
noteSpy: vi.fn(),
|
||||
@@ -13,25 +11,6 @@ vi.mock("../terminal/note.js", () => ({
|
||||
|
||||
import { loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow.js";
|
||||
|
||||
async function runDoctorConfigWithInput(params: {
|
||||
config: Record<string, unknown>;
|
||||
repair?: boolean;
|
||||
}) {
|
||||
return withTempHome(async (home) => {
|
||||
const configDir = path.join(home, ".openclaw");
|
||||
await fs.mkdir(configDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(configDir, "openclaw.json"),
|
||||
JSON.stringify(params.config, null, 2),
|
||||
"utf-8",
|
||||
);
|
||||
return loadAndMaybeMigrateDoctorConfig({
|
||||
options: { nonInteractive: true, repair: params.repair },
|
||||
confirm: async () => false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe("doctor config flow safe bins", () => {
|
||||
beforeEach(() => {
|
||||
noteSpy.mockClear();
|
||||
@@ -59,6 +38,7 @@ describe("doctor config flow safe bins", () => {
|
||||
],
|
||||
},
|
||||
},
|
||||
run: loadAndMaybeMigrateDoctorConfig,
|
||||
});
|
||||
|
||||
const cfg = result.cfg as {
|
||||
@@ -94,6 +74,7 @@ describe("doctor config flow safe bins", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
run: loadAndMaybeMigrateDoctorConfig,
|
||||
});
|
||||
|
||||
expect(noteSpy).toHaveBeenCalledWith(
|
||||
|
||||
Reference in New Issue
Block a user