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

Function TestRunPerFile_UnknownTool

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

Source from the content-addressed store, hash-verified

248}
249
250func TestRunPerFile_UnknownTool(t *testing.T) {
251 content := ""
252 unknownToolResp := &llm.ChatResponse{
253 Choices: []llm.Choice{{
254 Message: llm.ResponseMessage{
255 Content: &content,
256 ToolCalls: []llm.ToolCall{{
257 ID: "call_x",
258 Type: "function",
259 Function: llm.FunctionCall{
260 Name: "nonexistent_tool",
261 Arguments: `{}`,
262 },
263 }},
264 },
265 }},
266 Model: "fake",
267 Usage: &llm.UsageInfo{PromptTokens: 5, CompletionTokens: 5},
268 }
269 client := &fakeClient{responses: []*llm.ChatResponse{unknownToolResp, taskDoneResponse()}}
270 deps := newTestDeps(client)
271 runner := NewRunner(deps)
272
273 msgs := []llm.Message{llm.NewTextMessage("user", "review")}
274 completed, _, err := runner.RunPerFile(context.Background(), msgs, "main.go")
275 if err != nil {
276 t.Fatalf("RunPerFile: %v", err)
277 }
278 if !completed {
279 t.Fatal("expected task_done to complete RunPerFile")
280 }
281 if client.calls != 2 {
282 t.Errorf("expected 2 calls, got %d", client.calls)
283 }
284}
285
286func TestRunPerFile_MaxToolRequestsWithoutTaskDoneDoesNotComplete(t *testing.T) {
287 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