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

Function ExecuteToolWithInput

pkg/tools/builtin/testutils.go:109–128  ·  view source on GitHub ↗

ExecuteToolWithInput 使用指定输入执行工具

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

Source from the content-addressed store, hash-verified

107
108// ExecuteToolWithInput 使用指定输入执行工具
109func ExecuteToolWithInput(t *testing.T, tool tools.Tool, input map[string]any) map[string]any {
110 ctx := context.Background()
111 tc := &tools.ToolContext{
112 Signal: ctx,
113 Sandbox: NewMockToolContext(),
114 }
115
116 result, err := tool.Execute(ctx, input, tc)
117 if err != nil {
118 t.Fatalf("Tool execution failed: %v", err)
119 }
120
121 // 将result转换为map[string]any
122 if resultMap, ok := result.(map[string]any); ok {
123 return resultMap
124 }
125
126 t.Fatalf("Expected map[string]any result, got %T", result)
127 return nil
128}
129
130// ExecuteToolWithRealFS 使用真实文件系统执行工具
131func ExecuteToolWithRealFS(t *testing.T, tool tools.Tool, input map[string]any) map[string]any {

Calls 2

NewMockToolContextFunction · 0.85
ExecuteMethod · 0.65