返回 DeepSeek-Reasonix
context_command_test.go
根目录 / internal / control / context_command_test.go
1 package control
2
3 import (
4 "strings"
5 "testing"
6
7 "reasonix/internal/agent"
8 )
9
10 // "70% full" does not tell the user whether that is close to anything, so the
11 // summary names the next action for the pressure it reports.
12 func TestContextSummaryNamesTheNextAction(t *testing.T) {
13 base := agent.ContextReport{Window: 1000, SnipThreshold: 600, FoldThreshold: 800, ForceThreshold: 900}
14 for _, tc := range []struct {
15 name string
16 prompt int
17 want string
18 }{
19 {"below every threshold", 100, "fold at 80%"},
20 {"in the snip band", 650, "snipping stale tool results"},
21 {"at the fold threshold", 800, "folding"},
22 {"at the force threshold", 950, "at the force threshold"},
23 } {
24 t.Run(tc.name, func(t *testing.T) {
25 rep := base
26 rep.LatestPrompt = tc.prompt
27 if got := contextSummaryLine(rep); !strings.Contains(got, tc.want) {
28 t.Errorf("summary = %q, want it to mention %q", got, tc.want)
29 }
30 })
31 }
32 }
33
34 // A blocked maintenance pass is the thing users cannot currently see, so it has
35 // to reach the one-line summary rather than only the detail block.
36 func TestContextSummaryFlagsBlockedMaintenance(t *testing.T) {
37 rep := agent.ContextReport{
38 Window: 1000, SnipThreshold: 600, FoldThreshold: 800, ForceThreshold: 900,
39 LatestPrompt: 700, BlockedReason: "context summary failed: deadline exceeded",
40 }
41 if got := contextSummaryLine(rep); !strings.Contains(got, "blocked") {
42 t.Errorf("summary = %q, want it to flag the blocked pass", got)
43 }
44 }
45
46 func TestThousandsGroupsDigits(t *testing.T) {
47 for in, want := range map[int]string{
48 0: "0", 999: "999", 1000: "1,000", 731281: "731,281", 1048576: "1,048,576", -1234: "-1,234",
49 } {
50 if got := thousands(in); got != want {
51 t.Errorf("thousands(%d) = %q, want %q", in, got, want)
52 }
53 }
54 }
55
55 lines GO