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

Function TestRunPerFile_UnknownTool

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

Source from the content-addressed store, hash-verified

273}
274
275func TestRunPerFile_UnknownTool(t *testing.T) {
276 content := ""
277 unknownToolResp := &llm.ChatResponse{
278 Choices: []llm.Choice{{
279 Message: llm.ResponseMessage{
280 Content: &content,
281 ToolCalls: []llm.ToolCall{{
282 ID: "call_x",
283 Type: "function",
284 Function: llm.FunctionCall{
285 Name: "nonexistent_tool",
286 Arguments: `{}`,
287 },
288 }},
289 },
290 }},
291 Model: "fake",
292 Usage: &llm.UsageInfo{PromptTokens: 5, CompletionTokens: 5},
293 }
294 client := &fakeClient{responses: []*llm.ChatResponse{unknownToolResp, taskDoneResponse()}}
295 deps := newTestDeps(client)
296 runner := NewRunner(deps)
297
298 msgs := []llm.Message{llm.NewTextMessage("user", "review")}
299 completed, _, err := runner.RunPerFile(context.Background(), msgs, "main.go")
300 if err != nil {
301 t.Fatalf("RunPerFile: %v", err)
302 }
303 if !completed {
304 t.Fatal("expected task_done to complete RunPerFile")
305 }
306 if client.calls != 2 {
307 t.Errorf("expected 2 calls, got %d", client.calls)
308 }
309}
310
311func TestRunPerFile_MaxToolRequestsWithoutTaskDoneDoesNotComplete(t *testing.T) {
312 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