test(cli): add default agent resolution tests
Add unit tests for resolveRunAgent() covering: - CLI flag takes priority over env and config - Env var takes priority over config - Config takes priority over default - Falls back to sisyphus when none set - Skips disabled agent and picks next available core agent
This commit is contained in:
parent
dd3f93d3e7
commit
874d51a9f4
70
src/cli/run/runner.test.ts
Normal file
70
src/cli/run/runner.test.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { describe, it, expect } from "bun:test"
|
||||
import type { OhMyOpenCodeConfig } from "../../config"
|
||||
import { resolveRunAgent } from "./runner"
|
||||
|
||||
const createConfig = (overrides: Partial<OhMyOpenCodeConfig> = {}): OhMyOpenCodeConfig => ({
|
||||
...overrides,
|
||||
})
|
||||
|
||||
describe("resolveRunAgent", () => {
|
||||
it("uses CLI agent over env and config", () => {
|
||||
// given
|
||||
const config = createConfig({ default_run_agent: "prometheus" })
|
||||
const env = { OPENCODE_DEFAULT_AGENT: "Atlas" }
|
||||
|
||||
// when
|
||||
const agent = resolveRunAgent(
|
||||
{ message: "test", agent: "Hephaestus" },
|
||||
config,
|
||||
env
|
||||
)
|
||||
|
||||
// then
|
||||
expect(agent).toBe("hephaestus")
|
||||
})
|
||||
|
||||
it("uses env agent over config", () => {
|
||||
// given
|
||||
const config = createConfig({ default_run_agent: "prometheus" })
|
||||
const env = { OPENCODE_DEFAULT_AGENT: "Atlas" }
|
||||
|
||||
// when
|
||||
const agent = resolveRunAgent({ message: "test" }, config, env)
|
||||
|
||||
// then
|
||||
expect(agent).toBe("atlas")
|
||||
})
|
||||
|
||||
it("uses config agent over default", () => {
|
||||
// given
|
||||
const config = createConfig({ default_run_agent: "Prometheus" })
|
||||
|
||||
// when
|
||||
const agent = resolveRunAgent({ message: "test" }, config, {})
|
||||
|
||||
// then
|
||||
expect(agent).toBe("prometheus")
|
||||
})
|
||||
|
||||
it("falls back to sisyphus when none set", () => {
|
||||
// given
|
||||
const config = createConfig()
|
||||
|
||||
// when
|
||||
const agent = resolveRunAgent({ message: "test" }, config, {})
|
||||
|
||||
// then
|
||||
expect(agent).toBe("sisyphus")
|
||||
})
|
||||
|
||||
it("skips disabled sisyphus for next available core agent", () => {
|
||||
// given
|
||||
const config = createConfig({ disabled_agents: ["sisyphus"] })
|
||||
|
||||
// when
|
||||
const agent = resolveRunAgent({ message: "test" }, config, {})
|
||||
|
||||
// then
|
||||
expect(agent).toBe("hephaestus")
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user