diff options
| author | Dax Raad <[email protected]> | 2025-12-26 19:44:31 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-12-26 19:44:32 -0500 |
| commit | 2cdc88d295f3cdac432ea81657d2f5f9da2bde45 (patch) | |
| tree | b43d2ed90f28bd7da8e5a606b90a072c78afb201 | |
| parent | f8fb08b3b42007d6b1ab995e6c55d1996050de69 (diff) | |
| download | opencode-2cdc88d295f3cdac432ea81657d2f5f9da2bde45.tar.gz opencode-2cdc88d295f3cdac432ea81657d2f5f9da2bde45.zip | |
core: add compaction config tests to verify auto and prune settings work correctly
| -rw-r--r-- | packages/opencode/test/config/config.test.ts | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index 6f43cab61..8871fd50b 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -533,3 +533,97 @@ test("deduplicates duplicate plugins from global and local configs", async () => }, }) }) + +test("compaction config defaults to true when not specified", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + // When not specified, compaction should be undefined (defaults handled in usage) + expect(config.compaction).toBeUndefined() + }, + }) +}) + +test("compaction config can disable auto compaction", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + compaction: { + auto: false, + }, + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + expect(config.compaction?.auto).toBe(false) + expect(config.compaction?.prune).toBeUndefined() + }, + }) +}) + +test("compaction config can disable prune", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + compaction: { + prune: false, + }, + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + expect(config.compaction?.prune).toBe(false) + expect(config.compaction?.auto).toBeUndefined() + }, + }) +}) + +test("compaction config can disable both auto and prune", async () => { + await using tmp = await tmpdir({ + init: async (dir) => { + await Bun.write( + path.join(dir, "opencode.json"), + JSON.stringify({ + $schema: "https://opencode.ai/config.json", + compaction: { + auto: false, + prune: false, + }, + }), + ) + }, + }) + await Instance.provide({ + directory: tmp.path, + fn: async () => { + const config = await Config.get() + expect(config.compaction?.auto).toBe(false) + expect(config.compaction?.prune).toBe(false) + }, + }) +}) |
