test: cover tilde path expansion
This commit is contained in:
@@ -676,6 +676,20 @@ describe("Nix integration (U3, U5, U9)", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("CONFIG_PATH_CLAWDBOT expands ~ in CLAWDBOT_CONFIG_PATH override", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
await withEnvOverride(
|
||||
{ CLAWDBOT_CONFIG_PATH: "~/.clawdbot/custom.json" },
|
||||
async () => {
|
||||
const { CONFIG_PATH_CLAWDBOT } = await import("./config.js");
|
||||
expect(CONFIG_PATH_CLAWDBOT).toBe(
|
||||
path.join(home, ".clawdbot", "custom.json"),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("CONFIG_PATH_CLAWDBOT uses STATE_DIR_CLAWDBOT when only state dir is overridden", async () => {
|
||||
await withEnvOverride(
|
||||
{
|
||||
@@ -692,6 +706,71 @@ describe("Nix integration (U3, U5, U9)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("U5b: tilde expansion for config paths", () => {
|
||||
it("expands ~ in common path-ish config fields", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const configDir = path.join(home, ".clawdbot");
|
||||
await fs.mkdir(configDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(configDir, "clawdbot.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
plugins: {
|
||||
load: {
|
||||
paths: ["~/plugins/demo-plugin"],
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
defaults: { workspace: "~/ws-default" },
|
||||
list: [
|
||||
{
|
||||
id: "main",
|
||||
workspace: "~/ws-agent",
|
||||
agentDir: "~/.clawdbot/agents/main",
|
||||
sandbox: { workspaceRoot: "~/sandbox-root" },
|
||||
},
|
||||
],
|
||||
},
|
||||
whatsapp: {
|
||||
accounts: {
|
||||
personal: {
|
||||
authDir: "~/.clawdbot/credentials/wa-personal",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
vi.resetModules();
|
||||
const { loadConfig } = await import("./config.js");
|
||||
const cfg = loadConfig();
|
||||
|
||||
expect(cfg.plugins?.load?.paths?.[0]).toBe(
|
||||
path.join(home, "plugins", "demo-plugin"),
|
||||
);
|
||||
expect(cfg.agents?.defaults?.workspace).toBe(
|
||||
path.join(home, "ws-default"),
|
||||
);
|
||||
expect(cfg.agents?.list?.[0]?.workspace).toBe(
|
||||
path.join(home, "ws-agent"),
|
||||
);
|
||||
expect(cfg.agents?.list?.[0]?.agentDir).toBe(
|
||||
path.join(home, ".clawdbot", "agents", "main"),
|
||||
);
|
||||
expect(cfg.agents?.list?.[0]?.sandbox?.workspaceRoot).toBe(
|
||||
path.join(home, "sandbox-root"),
|
||||
);
|
||||
expect(cfg.whatsapp?.accounts?.personal?.authDir).toBe(
|
||||
path.join(home, ".clawdbot", "credentials", "wa-personal"),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("U6: gateway port resolution", () => {
|
||||
it("uses default when env and config are unset", async () => {
|
||||
await withEnvOverride({ CLAWDBOT_GATEWAY_PORT: undefined }, async () => {
|
||||
|
||||
Reference in New Issue
Block a user