返回 DeepSeek-Reasonix
history_shell_alias_test.go
根目录 / desktop / history_shell_alias_test.go
1 package main
2
3 import (
4 "reasonix/internal/provider"
5 "testing"
6 )
7
8 func TestHistoryPowerShellAliasesKeepArchivedCommand(t *testing.T) {
9 for _, name := range []string{"bash", "BASH", "pwsh", "PWSH", "powershell", "PowerShell", "shell"} {
10 msgs := []provider.Message{
11 {Role: provider.RoleAssistant, ToolCalls: []provider.ToolCall{{ID: "call", Name: name, Arguments: `{"command":"Write-Output example","description":"Display example"}`}}},
12 {Role: provider.RoleTool, Name: name, ToolCallID: "call", Content: "example\n"},
13 }
14 history := historyMessages(msgs, func(s string) string { return s })
15 call := history[0].ToolCalls[0]
16 if !call.ArgumentsArchived || call.Subject != "Write-Output example" || call.Summary == "" {
17 t.Fatalf("%s: %+v", name, call)
18 }
19 failed := historyMessages([]provider.Message{
20 {Role: provider.RoleAssistant, ToolCalls: []provider.ToolCall{{ID: "failed", Name: name, Arguments: `{"command":"exit 7"}`}}},
21 {Role: provider.RoleTool, Name: name, ToolCallID: "failed", Content: "error: command exited: exit status 7"},
22 }, func(s string) string { return s })
23 if got := failed[0].ToolCalls[0].Summary; got != "" {
24 t.Fatalf("%s failed summary = %q, want empty", name, got)
25 }
26 }
27 }
28
28 lines GO