返回 DeepSeek-Reasonix
run_completion_test.go
根目录 / internal / cli / run_completion_test.go
1 package cli
2
3 import (
4 "context"
5 "errors"
6 "fmt"
7 "testing"
8
9 "reasonix/internal/agent"
10 )
11
12 func TestClassifyRunCompletionNamesTheFailureClass(t *testing.T) {
13 for _, tc := range []struct {
14 err error
15 want string
16 }{
17 {nil, "success"},
18 {&agent.FinalReadinessError{Attempts: 3, Reason: "incomplete todos"}, "final_readiness"},
19 {&agent.RecoveryPauseError{Message: "paused"}, "recovery_paused"},
20 {fmt.Errorf("run: %w", context.DeadlineExceeded), "timeout"},
21 {context.Canceled, "cancelled"},
22 {errors.New("provider 500"), "error_during_execution"},
23 } {
24 if got := classifyRunCompletion(tc.err).class; got != tc.want {
25 t.Errorf("class for %v = %q, want %q", tc.err, got, tc.want)
26 }
27 }
28 }
29
30 func TestFailureClassDoesNotChangeExitBehaviour(t *testing.T) {
31 readiness := classifyRunCompletion(&agent.FinalReadinessError{Attempts: 3})
32 if !readiness.isError || readiness.exitCode != 1 || readiness.outcome != "" {
33 t.Fatalf("final-readiness completion = %+v, want the unchanged error exit", readiness)
34 }
35 if readiness.subtype != "error_during_execution" {
36 t.Fatalf("subtype = %q, want the unchanged wire subtype", readiness.subtype)
37 }
38 }
39
39 lines GO