| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestGoalAutoResearchCanBeForcedOrDisabled(t *testing.T) { |
| 9 | c := newOwnedTestController(t, Options{}) |
| 10 | c.SetGoalWithResearchMode("fix the typo and add a test", GoalResearchOn) |
| 11 | if got := c.Compose("start"); strings.Contains(strings.ToLower(got), "autoresearch") || c.goals.budgetClass != budgetClassResearch { |
| 12 | t.Fatalf("forced research Goal should select the research class: %q %q", got, c.goals.budgetClass) |
| 13 | } |
| 14 | if c.GoalRuntime().TurnsLimit != 0 { |
| 15 | t.Fatalf("forced research compatibility flag selected a turn quota: %+v", c.GoalRuntime()) |
| 16 | } |
| 17 | |
| 18 | c.SetGoalWithResearchMode("持续排查这个线上卡顿直到根因明确", GoalResearchOff) |
| 19 | if got := c.Compose("start"); strings.Contains(strings.ToLower(got), "autoresearch") || c.goals.budgetClass == budgetClassResearch { |
| 20 | t.Fatalf("simple override should not select the research class: %q %q", got, c.goals.budgetClass) |
| 21 | } |
| 22 | if c.GoalRuntime().TurnsLimit != 0 { |
| 23 | t.Fatalf("simple compatibility flag selected a turn quota: %+v", c.GoalRuntime()) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestGoalCommandPreservesResearchModeFlags(t *testing.T) { |
| 28 | c := newOwnedTestController(t, Options{}) |
| 29 | if !c.applyGoalCommand("/goal --research fix the typo", "") { |
| 30 | t.Fatal("goal command was not parsed") |
| 31 | } |
| 32 | if got := c.Compose("start"); strings.Contains(strings.ToLower(got), "autoresearch") || c.goals.budgetClass != budgetClassResearch { |
| 33 | t.Fatalf("/goal --research should select the research class: %q %q", got, c.goals.budgetClass) |
| 34 | } |
| 35 | if c.GoalRuntime().TurnsLimit != 0 { |
| 36 | t.Fatalf("/goal --research selected a turn quota: %+v", c.GoalRuntime()) |
| 37 | } |
| 38 | |
| 39 | c = newOwnedTestController(t, Options{}) |
| 40 | if !c.applyGoalCommand("/goal --simple 持续排查这个线上卡顿直到根因明确", "") { |
| 41 | t.Fatal("goal command was not parsed") |
| 42 | } |
| 43 | if got := c.Compose("start"); strings.Contains(strings.ToLower(got), "autoresearch") || c.GoalRuntime().TurnsLimit != 0 { |
| 44 | t.Fatalf("/goal --simple must not select a turn quota: %q %+v", got, c.GoalRuntime()) |
| 45 | } |
| 46 | } |
| 47 |