package domain import ( "git.cin.su/m/Assistant/contracts/work" "testing" ) func TestSolutionSearchDoesNotDeadEndAfterBudgetedWave(t *testing.T) { decision, err := DecideSolutionSearch(work.SolutionSearchInput{GoalID: "goal-1", GoalState: work.GoalInProgress, SearchRound: 3, MaxRound: 3, Unresolved: true}) if err != nil { t.Fatal(err) } if !decision.ContinueSearching || decision.State != work.OrchestrationWaiting || decision.NextSearchRound != 4 { t.Fatalf("unexpected exhausted-wave decision: %#v", decision) } if len(decision.Options) != 5 || decision.Options[4] != work.SearchOptionHuman { t.Fatalf("all search avenues were not retained: %#v", decision.Options) } } func TestSolutionSearchStopsOnlyForCancelOrVerifiedCompletion(t *testing.T) { completed, err := DecideSolutionSearch(work.SolutionSearchInput{GoalID: "goal-1", GoalState: work.GoalCompleted, VerificationReady: true, MaxRound: 1}) if err != nil || completed.ContinueSearching || completed.State != work.OrchestrationCompleted { t.Fatalf("verified completion was not terminal: %#v %v", completed, err) } cancelled, err := DecideSolutionSearch(work.SolutionSearchInput{GoalID: "goal-1", GoalState: work.GoalInProgress, CancelRequested: true, MaxRound: 1}) if err != nil || cancelled.ContinueSearching || cancelled.State != work.OrchestrationCancelled { t.Fatalf("cancel was not terminal: %#v %v", cancelled, err) } }