refactor(config-manager): remove legacy config path detection and migration logic
🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { describe, it, expect } from "bun:test"
|
||||
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import * as config from "./config"
|
||||
|
||||
describe("config check", () => {
|
||||
@@ -23,5 +26,34 @@ describe("config check", () => {
|
||||
//#then issues should be an array (possibly empty)
|
||||
expect(Array.isArray(result.issues)).toBe(true)
|
||||
})
|
||||
|
||||
it("respects OPENCODE_CONFIG_DIR even when the env var changes after module import", async () => {
|
||||
const originalConfigDir = process.env.OPENCODE_CONFIG_DIR
|
||||
const testConfigDir = join(
|
||||
tmpdir(),
|
||||
`omo-doctor-config-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
||||
)
|
||||
|
||||
try {
|
||||
mkdirSync(testConfigDir, { recursive: true })
|
||||
process.env.OPENCODE_CONFIG_DIR = testConfigDir
|
||||
writeFileSync(
|
||||
join(testConfigDir, "oh-my-openagent.json"),
|
||||
JSON.stringify({ disabled_hooks: ["comment-checker"] }, null, 2) + "\n",
|
||||
"utf-8",
|
||||
)
|
||||
|
||||
const result = await config.checkConfig()
|
||||
|
||||
expect(result.details?.[0]).toEndWith("/oh-my-openagent.json")
|
||||
} finally {
|
||||
rmSync(testConfigDir, { recursive: true, force: true })
|
||||
if (originalConfigDir === undefined) {
|
||||
delete process.env.OPENCODE_CONFIG_DIR
|
||||
} else {
|
||||
process.env.OPENCODE_CONFIG_DIR = originalConfigDir
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test"
|
||||
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
|
||||
import { loadOmoConfig } from "./model-resolution-config"
|
||||
|
||||
describe("model-resolution-config", () => {
|
||||
let originalConfigDir: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
originalConfigDir = process.env.OPENCODE_CONFIG_DIR
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (originalConfigDir === undefined) {
|
||||
delete process.env.OPENCODE_CONFIG_DIR
|
||||
} else {
|
||||
process.env.OPENCODE_CONFIG_DIR = originalConfigDir
|
||||
}
|
||||
})
|
||||
|
||||
it("respects OPENCODE_CONFIG_DIR even when the env var changes after module import", () => {
|
||||
const testConfigDir = join(
|
||||
tmpdir(),
|
||||
`omo-model-resolution-config-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
||||
)
|
||||
|
||||
try {
|
||||
mkdirSync(testConfigDir, { recursive: true })
|
||||
process.env.OPENCODE_CONFIG_DIR = testConfigDir
|
||||
writeFileSync(
|
||||
join(testConfigDir, "oh-my-openagent.json"),
|
||||
JSON.stringify({ agents: { atlas: { model: "opencode-go/kimi-k2.5" } } }, null, 2) + "\n",
|
||||
"utf-8",
|
||||
)
|
||||
|
||||
const config = loadOmoConfig()
|
||||
|
||||
expect(config?.agents?.atlas?.model).toBe("opencode-go/kimi-k2.5")
|
||||
} finally {
|
||||
rmSync(testConfigDir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user