summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/opencode/test/config/config.test.ts94
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)
+ },
+ })
+})