mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 05:37:27 +00:00
test(config): dedupe io fixture wiring and cover legacy config-path override
This commit is contained in:
@@ -26,14 +26,18 @@ async function writeConfig(
|
||||
return configPath;
|
||||
}
|
||||
|
||||
function createIoForHome(home: string, env: NodeJS.ProcessEnv = {} as NodeJS.ProcessEnv) {
|
||||
return createConfigIO({
|
||||
env,
|
||||
homedir: () => home,
|
||||
});
|
||||
}
|
||||
|
||||
describe("config io paths", () => {
|
||||
it("uses ~/.openclaw/openclaw.json when config exists", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const configPath = await writeConfig(home, ".openclaw", 19001);
|
||||
const io = createConfigIO({
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
homedir: () => home,
|
||||
});
|
||||
const io = createIoForHome(home);
|
||||
expect(io.configPath).toBe(configPath);
|
||||
expect(io.loadConfig().gateway?.port).toBe(19001);
|
||||
});
|
||||
@@ -41,10 +45,7 @@ describe("config io paths", () => {
|
||||
|
||||
it("defaults to ~/.openclaw/openclaw.json when config is missing", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const io = createConfigIO({
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
homedir: () => home,
|
||||
});
|
||||
const io = createIoForHome(home);
|
||||
expect(io.configPath).toBe(path.join(home, ".openclaw", "openclaw.json"));
|
||||
});
|
||||
});
|
||||
@@ -62,12 +63,18 @@ describe("config io paths", () => {
|
||||
it("honors explicit OPENCLAW_CONFIG_PATH override", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const customPath = await writeConfig(home, ".openclaw", 20002, "custom.json");
|
||||
const io = createConfigIO({
|
||||
env: { OPENCLAW_CONFIG_PATH: customPath } as NodeJS.ProcessEnv,
|
||||
homedir: () => home,
|
||||
});
|
||||
const io = createIoForHome(home, { OPENCLAW_CONFIG_PATH: customPath } as NodeJS.ProcessEnv);
|
||||
expect(io.configPath).toBe(customPath);
|
||||
expect(io.loadConfig().gateway?.port).toBe(20002);
|
||||
});
|
||||
});
|
||||
|
||||
it("honors legacy CLAWDBOT_CONFIG_PATH override", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const customPath = await writeConfig(home, ".openclaw", 20003, "legacy-custom.json");
|
||||
const io = createIoForHome(home, { CLAWDBOT_CONFIG_PATH: customPath } as NodeJS.ProcessEnv);
|
||||
expect(io.configPath).toBe(customPath);
|
||||
expect(io.loadConfig().gateway?.port).toBe(20003);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user