This commit is contained in:
YeonGyu-Kim
2026-05-27 13:58:58 +09:00
parent 73e8988f31
commit db00bb3d42
18 changed files with 21606 additions and 431 deletions
@@ -0,0 +1,98 @@
/// <reference types="bun-types" />
import { describe, expect, test } from "bun:test"
import { readFile } from "node:fs/promises"
import path from "node:path"
import { resolveInstallArgs } from "./cli-program"
describe("install platform resolution", () => {
test("leaves omo install without --platform unresolved for config defaults", () => {
// given
const invocationName = "omo"
// when
const args = resolveInstallArgs({ tui: true }, invocationName)
// then
expect(args.platform).toBeUndefined()
})
test("resolves explicit --platform=codex", () => {
// given
const invocationName = "omo"
// when
const args = resolveInstallArgs({ tui: true, platform: "codex" }, invocationName)
// then
expect(args.platform).toBe("codex")
})
test("resolves explicit --platform=both", () => {
// given
const invocationName = "omo"
// when
const args = resolveInstallArgs({ tui: true, platform: "both" }, invocationName)
// then
expect(args.platform).toBe("both")
})
test("resolves explicit --platform=opencode", () => {
// given
const invocationName = "omo"
// when
const args = resolveInstallArgs({ tui: true, platform: "opencode" }, invocationName)
// then
expect(args.platform).toBe("opencode")
})
test("defaults lazycodex install to codex platform", () => {
// given
const invocationName = "lazycodex"
// when
const args = resolveInstallArgs({ tui: true }, invocationName)
// then
expect(args.platform).toBe("codex")
})
test("lets lazycodex install explicitly override to both", () => {
// given
const invocationName = "lazycodex"
// when
const args = resolveInstallArgs({ tui: true, platform: "both" }, invocationName)
// then
expect(args.platform).toBe("both")
})
test("lets lazycodex install explicitly override to opencode", () => {
// given
const invocationName = "lazycodex"
// when
const args = resolveInstallArgs({ tui: true, platform: "opencode" }, invocationName)
// then
expect(args.platform).toBe("opencode")
})
test("defines Commander choices so invalid --platform values are rejected", async () => {
// given
const cliProgramSource = await readFile(path.resolve(import.meta.dir, "cli-program.ts"), "utf-8")
// when
const installBlock = cliProgramSource.match(/program\s*\n\s*\.command\("install"\)([\s\S]*?)\.action\(/)
// then
expect(installBlock).not.toBeNull()
expect(installBlock?.[1]).toContain('new Option("--platform <platform>"')
expect(installBlock?.[1]).toContain('.choices(["opencode", "codex", "both"])')
})
})