(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func TestInjectDiffMap(t *testing.T) { |
| 113 | reg := tool.NewRegistry() |
| 114 | emptyDM := tool.NewDiffMap(nil) |
| 115 | frd := tool.NewFileReadDiff(emptyDM) |
| 116 | reg.Register(frd) |
| 117 | |
| 118 | a := New(Args{ |
| 119 | LLMClient: &fakeAgentClient{}, |
| 120 | Tools: reg, |
| 121 | Template: template.Template{MaxTokens: 10000, MaxToolRequestTimes: 5, MainTask: template.LlmConversation{Messages: []template.ChatMessage{{Role: "user", Content: "t"}}}}, |
| 122 | }) |
| 123 | a.diffs = []model.Diff{ |
| 124 | {NewPath: "main.go", OldPath: "main.go", Diff: "+new code"}, |
| 125 | {NewPath: "/dev/null", OldPath: "deleted.go", Diff: "-deleted"}, |
| 126 | } |
| 127 | |
| 128 | a.injectDiffMap() |
| 129 | |
| 130 | result, err := frd.Execute(context.Background(), map[string]any{ |
| 131 | "path_array": []any{"main.go"}, |
| 132 | }) |
| 133 | if err != nil { |
| 134 | t.Fatal(err) |
| 135 | } |
| 136 | if !strings.Contains(result, "+new code") { |
| 137 | t.Errorf("DiffMap did not contain main.go diff, got: %q", result) |
| 138 | } |
| 139 | |
| 140 | result2, _ := frd.Execute(context.Background(), map[string]any{ |
| 141 | "path_array": []any{"deleted.go"}, |
| 142 | }) |
| 143 | if !strings.Contains(result2, "not found") { |
| 144 | t.Errorf("/dev/null path should not be in DiffMap, got: %q", result2) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestFilterDiffs(t *testing.T) { |
| 149 | a := New(Args{ |
nothing calls this directly
no test coverage detected