MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestRunPerFile_UnknownTool

Function TestRunPerFile_UnknownTool

internal/llmloop/loop_test.go:168–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

166}
167
168func TestRunPerFile_UnknownTool(t *testing.T) {
169 content := ""
170 unknownToolResp := &llm.ChatResponse{
171 Choices: []llm.Choice{{
172 Message: llm.ResponseMessage{
173 Content: &content,
174 ToolCalls: []llm.ToolCall{{
175 ID: "call_x",
176 Type: "function",
177 Function: llm.FunctionCall{
178 Name: "nonexistent_tool",
179 Arguments: `{}`,
180 },
181 }},
182 },
183 }},
184 Model: "fake",
185 Usage: &llm.UsageInfo{PromptTokens: 5, CompletionTokens: 5},
186 }
187 client := &fakeClient{responses: []*llm.ChatResponse{unknownToolResp, taskDoneResponse()}}
188 deps := newTestDeps(client)
189 runner := NewRunner(deps)
190
191 msgs := []llm.Message{llm.NewTextMessage("user", "review")}
192 completed, err := runner.RunPerFile(context.Background(), msgs, "main.go")
193 if err != nil {
194 t.Fatalf("RunPerFile: %v", err)
195 }
196 if !completed {
197 t.Fatal("expected task_done to complete RunPerFile")
198 }
199 if client.calls != 2 {
200 t.Errorf("expected 2 calls, got %d", client.calls)
201 }
202}
203
204func TestRunPerFile_MaxToolRequestsWithoutTaskDoneDoesNotComplete(t *testing.T) {
205 content := ""

Callers

nothing calls this directly

Calls 5

RunPerFileMethod · 0.95
NewTextMessageFunction · 0.92
taskDoneResponseFunction · 0.85
newTestDepsFunction · 0.85
NewRunnerFunction · 0.85

Tested by

no test coverage detected