MCPcopy Create free account
hub / github.com/astercloud/aster / ExecuteToolWithoutContext

Function ExecuteToolWithoutContext

pkg/tools/builtin/testutils.go:176–191  ·  view source on GitHub ↗

ExecuteToolWithoutContext 不使用 ToolContext 执行工具(用于测试不依赖 sandbox 的工具)

(t *testing.T, tool tools.Tool, input map[string]any)

Source from the content-addressed store, hash-verified

174
175// ExecuteToolWithoutContext 不使用 ToolContext 执行工具(用于测试不依赖 sandbox 的工具)
176func ExecuteToolWithoutContext(t *testing.T, tool tools.Tool, input map[string]any) map[string]any {
177 ctx := context.Background()
178
179 result, err := tool.Execute(ctx, input, nil)
180 if err != nil {
181 t.Fatalf("Tool execution failed: %v", err)
182 }
183
184 // 将result转换为map[string]any
185 if resultMap, ok := result.(map[string]any); ok {
186 return resultMap
187 }
188
189 t.Fatalf("Expected map[string]any result, got %T", result)
190 return nil
191}
192
193// CustomWorkDirSandbox 自定义工作目录的沙箱(仅用于测试)
194type CustomWorkDirSandbox struct {

Callers

nothing calls this directly

Calls 1

ExecuteMethod · 0.65

Tested by

no test coverage detected