mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 23:40:45 +00:00
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { withTempHome } from "./test-helpers.js";
|
|
|
|
describe("config pruning defaults", () => {
|
|
it("defaults contextPruning mode to adaptive", 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({ agents: { defaults: {} } }, null, 2),
|
|
"utf-8",
|
|
);
|
|
|
|
vi.resetModules();
|
|
const { loadConfig } = await import("./config.js");
|
|
const cfg = loadConfig();
|
|
|
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("adaptive");
|
|
});
|
|
});
|
|
|
|
it("does not override explicit contextPruning mode", 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({ agents: { defaults: { contextPruning: { mode: "off" } } } }, null, 2),
|
|
"utf-8",
|
|
);
|
|
|
|
vi.resetModules();
|
|
const { loadConfig } = await import("./config.js");
|
|
const cfg = loadConfig();
|
|
|
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("off");
|
|
});
|
|
});
|
|
});
|