Skip to content

Commit 0fcf55b

Browse files
committed
test(cli): lock auto and interactive contracts
1 parent ac4c7f5 commit 0fcf55b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/test/java/io/github/easy4j/opencode/cli/OpenCodeRunOptionsContractTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@
1515
*/
1616
class OpenCodeRunOptionsContractTest {
1717

18+
@Test
19+
void autoApprovalMustBeOptInBooleanSwitch() {
20+
OpenCodeRunOptions disabled = new OpenCodeRunOptions("hello");
21+
List<String> disabledArgs = Arrays.asList(disabled.toArgs());
22+
assertFalse(disabledArgs.contains("--auto"), "--auto must be disabled by default");
23+
24+
OpenCodeRunOptions enabled = new OpenCodeRunOptions("hello");
25+
Method auto = assertDoesNotThrow(
26+
() -> OpenCodeRunOptions.class.getMethod("auto", boolean.class),
27+
"OpenCode run --auto must be explicitly modeled");
28+
assertDoesNotThrow(() -> auto.invoke(enabled, true));
29+
30+
List<String> enabledArgs = Arrays.asList(enabled.toArgs());
31+
assertTrue(enabledArgs.contains("--auto"));
32+
}
33+
34+
@Test
35+
void interactiveModeMustBeExplicitlyModeled() {
36+
OpenCodeRunOptions options = new OpenCodeRunOptions("hello");
37+
Method interactive = assertDoesNotThrow(
38+
() -> OpenCodeRunOptions.class.getMethod("interactive", boolean.class),
39+
"OpenCode run --interactive must be explicitly modeled");
40+
assertDoesNotThrow(() -> interactive.invoke(options, true));
41+
42+
assertTrue(Arrays.asList(options.toArgs()).contains("--interactive"));
43+
}
44+
1845
@Test
1946
void shareMustBeBooleanSwitchWithoutValue() {
2047
OpenCodeRunOptions options = new OpenCodeRunOptions("hello");

0 commit comments

Comments
 (0)