返回 DeepSeek-Reasonix
final_readiness_history_test.go
根目录 / desktop / final_readiness_history_test.go
1 package main
2
3 import (
4 "encoding/json"
5 "strings"
6 "testing"
7
8 "reasonix/internal/agent"
9 "reasonix/internal/provider"
10 )
11
12 func TestHistoryMessagesRestorePendingFinalReadinessAction(t *testing.T) {
13 marker := provider.Message{
14 Role: provider.RoleTool, ToolCallID: provider.LocalOnlyToolID, Name: provider.LocalOnlyToolName, LocalOnly: true,
15 FinalReadinessRecovery: &provider.FinalReadinessRecovery{Pending: true, Missing: []string{"verification", "review"}},
16 }
17 got := historyMessages([]provider.Message{
18 {Role: provider.RoleUser, Content: "fix it"},
19 {Role: provider.RoleAssistant, Content: "partial result"},
20 marker,
21 }, strings.TrimSpace)
22 if len(got) != 3 || got[2].Role != "notice" || got[2].Code != agent.HistoricalChecksNoticeCode || got[2].Pending || got[2].Readiness == nil {
23 t.Fatalf("pending readiness history row = %+v", got)
24 }
25 if missing := got[2].Readiness.Missing; len(missing) != 2 || missing[0] != "verification" || missing[1] != "review" {
26 t.Fatalf("pending readiness missing = %v", missing)
27 }
28 wired, err := json.Marshal(got[2])
29 if err != nil {
30 t.Fatalf("marshal pending readiness: %v", err)
31 }
32 if text := string(wired); !strings.Contains(text, `"readiness":{"attempts":1,"missing":["verification","review"]}`) || strings.Contains(text, `"Attempts"`) {
33 t.Fatalf("pending readiness JSON = %s, want frontend-compatible camel case", text)
34 }
35
36 marker.FinalReadinessRecovery.Pending = false
37 consumed := historyMessages([]provider.Message{{Role: provider.RoleUser, Content: "fix it"}, marker}, strings.TrimSpace)
38 if len(consumed) != 1 {
39 t.Fatalf("consumed readiness marker should be hidden: %+v", consumed)
40 }
41 }
42
42 lines GO