ExecuteToolWithRealFS 使用真实文件系统执行工具
(t *testing.T, tool tools.Tool, input map[string]any)
| 129 | |
| 130 | // ExecuteToolWithRealFS 使用真实文件系统执行工具 |
| 131 | func ExecuteToolWithRealFS(t *testing.T, tool tools.Tool, input map[string]any) map[string]any { |
| 132 | ctx := context.Background() |
| 133 | // 使用真实的文件系统而不是Mock |
| 134 | tc := &tools.ToolContext{ |
| 135 | Signal: ctx, |
| 136 | Sandbox: &RealSandbox{}, |
| 137 | } |
| 138 | |
| 139 | result, err := tool.Execute(ctx, input, tc) |
| 140 | if err != nil { |
| 141 | t.Fatalf("Tool execution failed: %v", err) |
| 142 | } |
| 143 | |
| 144 | // 将result转换为map[string]any |
| 145 | if resultMap, ok := result.(map[string]any); ok { |
| 146 | return resultMap |
| 147 | } |
| 148 | |
| 149 | t.Fatalf("Expected map[string]any result, got %T", result) |
| 150 | return nil |
| 151 | } |
| 152 | |
| 153 | // ExecuteToolWithWorkDir 使用指定工作目录执行工具 |
| 154 | func ExecuteToolWithWorkDir(t *testing.T, tool tools.Tool, input map[string]any, workDir string) map[string]any { |