Files
oh-my-openagent/src/cli/run/runner.test.ts
YeonGyu-Kim 874d51a9f4 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
2026-02-02 13:13:06 +09:00

71 lines
1.7 KiB
TypeScript

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")
})
})