(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestInjectDiffMap(t *testing.T) { |
| 120 | reg := tool.NewRegistry() |
| 121 | emptyDM := tool.NewDiffMap(nil) |
| 122 | frd := tool.NewFileReadDiff(emptyDM) |
| 123 | reg.Register(frd) |
| 124 | |
| 125 | a := New(Args{ |
| 126 | LLMClient: &fakeAgentClient{}, |
| 127 | Tools: reg, |
| 128 | Template: template.Template{MaxTokens: 10000, MaxToolRequestTimes: 5, MainTask: template.LlmConversation{Messages: []template.ChatMessage{{Role: "user", Content: "t"}}}}, |
| 129 | }) |
| 130 | a.diffs = []model.Diff{ |
| 131 | {NewPath: "main.go", OldPath: "main.go", Diff: "+new code"}, |
| 132 | {NewPath: "/dev/null", OldPath: "deleted.go", Diff: "-deleted", IsDeleted: true}, |
| 133 | {NewPath: "renamed.go", OldPath: "old_name.go", Diff: "+renamed", IsRenamed: true}, |
| 134 | } |
| 135 | |
| 136 | a.injectDiffMap() |
| 137 | |
| 138 | result, err := frd.Execute(context.Background(), map[string]any{ |
| 139 | "path_array": []any{"main.go"}, |
| 140 | }) |
| 141 | if err != nil { |
| 142 | t.Fatal(err) |
| 143 | } |
| 144 | if !strings.Contains(result, "+new code") { |
| 145 | t.Errorf("DiffMap did not contain main.go diff, got: %q", result) |
| 146 | } |
| 147 | |
| 148 | result2, _ := frd.Execute(context.Background(), map[string]any{ |
| 149 | "path_array": []any{"deleted.go"}, |
| 150 | }) |
| 151 | if !strings.Contains(result2, "-deleted") { |
| 152 | t.Errorf("DiffMap did not contain deleted.go diff, got: %q", result2) |
| 153 | } |
| 154 | |
| 155 | result3, _ := frd.Execute(context.Background(), map[string]any{ |
| 156 | "path_array": []any{"renamed.go"}, |
| 157 | }) |
| 158 | if !strings.Contains(result3, "+renamed") { |
| 159 | t.Errorf("DiffMap did not contain renamed.go diff, got: %q", result3) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func TestSelectFilesDropsFilteredPaths(t *testing.T) { |
| 164 | a := New(Args{ |
nothing calls this directly
no test coverage detected