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

Function ExecuteToolWithRealFS

pkg/tools/builtin/testutils.go:131–151  ·  view source on GitHub ↗

ExecuteToolWithRealFS 使用真实文件系统执行工具

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

Source from the content-addressed store, hash-verified

129
130// ExecuteToolWithRealFS 使用真实文件系统执行工具
131func 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 使用指定工作目录执行工具
154func ExecuteToolWithWorkDir(t *testing.T, tool tools.Tool, input map[string]any, workDir string) map[string]any {

Callers 15

TestReadTool_SuccessFunction · 0.85
TestReadTool_EmptyFileFunction · 0.85
TestReadTool_LargeFileFunction · 0.85
TestReadTool_BinaryFileFunction · 0.85
TestEditTool_SimpleEditFunction · 0.85
TestEditTool_SameStringFunction · 0.85

Calls 1

ExecuteMethod · 0.65

Tested by 15

TestReadTool_SuccessFunction · 0.68
TestReadTool_EmptyFileFunction · 0.68
TestReadTool_LargeFileFunction · 0.68
TestReadTool_BinaryFileFunction · 0.68
TestEditTool_SimpleEditFunction · 0.68
TestEditTool_SameStringFunction · 0.68