mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-11 16:52:16 +03:00
test(cli): expect repeated optional-value flags to be rejected (#60786)
This commit is contained in:
committed by
GitHub
Unverified
parent
922f522242
commit
fb451648c0
@@ -55,14 +55,15 @@ test("leaves the next flag and its value alone", async () => {
|
||||
expect(result.input).toEqual({ worktree: Option.some(true), message: ["hi"], model: Option.some("openai/gpt") })
|
||||
})
|
||||
|
||||
// Matches every other single-value flag, where `--model a --model b` keeps `a`.
|
||||
// Matches every other single-value flag, where `--model a --model b` is rejected.
|
||||
test.each([
|
||||
{ args: ["-w", "--worktree=feature"], worktree: Option.some(true) },
|
||||
{ args: ["--worktree=feature", "-w"], worktree: Option.some("feature") },
|
||||
])("keeps the first of repeated flags: $args", async ({ args, worktree }) => {
|
||||
{ args: ["-w", "--worktree=feature"] },
|
||||
{ args: ["--worktree=feature", "-w"] },
|
||||
{ args: ["--model", "a", "--model", "b"] },
|
||||
])("rejects repeated flags: $args", async ({ args }) => {
|
||||
const result = await parse(args)
|
||||
expect(Exit.isSuccess(result.exit)).toBe(true)
|
||||
expect(result.input).toEqual({ worktree, message: [], model: Option.none() })
|
||||
expect(Exit.isFailure(result.exit)).toBe(true)
|
||||
expect(result.input).toBeUndefined()
|
||||
})
|
||||
|
||||
test("renders the value as optional in help", async () => {
|
||||
|
||||
Reference in New Issue
Block a user