(t *testing.T)
| 234 | } |
| 235 | |
| 236 | func TestRecoverFromTextShellFallback(t *testing.T) { |
| 237 | tools := []official.Tool{ |
| 238 | {Type: "function", Function: official.ToolFunction{Name: "bash", Parameters: json.RawMessage(`{"properties":{"command":{"type":"string"}}}`)}}, |
| 239 | } |
| 240 | // 模型输出沙箱格式 |
| 241 | text := `{"cmd": ["powershell", "-Command", "Get-Process"]}` |
| 242 | calls := RecoverFromText(text, tools) |
| 243 | if len(calls) != 1 { |
| 244 | t.Fatalf("calls = %d", len(calls)) |
| 245 | } |
| 246 | if calls[0].Function.Name != "bash" { |
| 247 | t.Fatalf("name = %q", calls[0].Function.Name) |
| 248 | } |
| 249 | if !strings.Contains(calls[0].Function.Arguments, "Get-Process") { |
| 250 | t.Fatalf("args = %q", calls[0].Function.Arguments) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func TestRecoverFromTextDeduplicates(t *testing.T) { |
| 255 | tools := []official.Tool{ |
nothing calls this directly
no test coverage detected