TestAuditTool_MultiRunDiffMode verifies that when run_ids_or_urls contains multiple entries the audit tool passes all of them as positional arguments to the audit command (which then runs in diff mode).
(t *testing.T)
| 537 | // multiple entries the audit tool passes all of them as positional arguments |
| 538 | // to the audit command (which then runs in diff mode). |
| 539 | func TestAuditTool_MultiRunDiffMode(t *testing.T) { |
| 540 | const expectedStdout = `[{"base_run_id":111,"compare_run_id":222}]` |
| 541 | |
| 542 | var capturedArgs []string |
| 543 | mockExecCmd := func(ctx context.Context, args ...string) *exec.Cmd { |
| 544 | capturedArgs = slices.Clone(args) |
| 545 | return exec.CommandContext(ctx, "sh", "-c", `printf '%s' "$1"`, "sh", expectedStdout) |
| 546 | } |
| 547 | |
| 548 | server := mcp.NewServer(&mcp.Implementation{Name: "test", Version: "1.0"}, nil) |
| 549 | err := registerAuditTool(server, mockExecCmd, "", false) |
| 550 | require.NoError(t, err, "registerAuditTool should succeed") |
| 551 | |
| 552 | session := connectInMemory(t, server) |
| 553 | result, err := session.CallTool(context.Background(), &mcp.CallToolParams{ |
| 554 | Name: "audit", |
| 555 | Arguments: map[string]any{ |
| 556 | "run_ids_or_urls": []string{"111", "222", "333"}, |
| 557 | }, |
| 558 | }) |
| 559 | require.NoError(t, err, "audit tool should succeed with multiple run IDs") |
| 560 | require.NotNil(t, result, "result should not be nil") |
| 561 | assert.False(t, result.IsError, "result should not be an error") |
| 562 | |
| 563 | textContent, ok := result.Content[0].(*mcp.TextContent) |
| 564 | require.True(t, ok, "expected text content in audit response") |
| 565 | assert.JSONEq(t, expectedStdout, textContent.Text, "audit tool should return subprocess stdout") |
| 566 | |
| 567 | // All three run IDs must appear as positional args immediately after "audit" |
| 568 | require.GreaterOrEqual(t, len(capturedArgs), 4, "captured args should include audit + 3 run IDs: %v", capturedArgs) |
| 569 | assert.Equal(t, "audit", capturedArgs[0], "first arg should be 'audit'") |
| 570 | assert.Equal(t, "111", capturedArgs[1], "second arg should be first run ID") |
| 571 | assert.Equal(t, "222", capturedArgs[2], "third arg should be second run ID") |
| 572 | assert.Equal(t, "333", capturedArgs[3], "fourth arg should be third run ID") |
| 573 | } |
| 574 | |
| 575 | // TestAuditTool_FailsWhenNoRunIDProvided verifies that the audit tool |
| 576 | // returns an error when neither run_id_or_url nor run_ids_or_urls is provided. |
nothing calls this directly
no test coverage detected