mirror of
https://github.com/ollama/ollama.git
synced 2026-07-06 07:41:05 +00:00
33 lines
981 B
Go
33 lines
981 B
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestToolInvocationLabelTruncatesLongBashCommand(t *testing.T) {
|
|
command := strings.Repeat("a", 101)
|
|
label := ToolInvocationLabel("bash", map[string]any{"command": command})
|
|
want := `Bash("` + strings.Repeat("a", 100) + `...")`
|
|
if label != want {
|
|
t.Fatalf("label = %q, want %q", label, want)
|
|
}
|
|
}
|
|
|
|
func TestToolInvocationLabelCountsRunes(t *testing.T) {
|
|
command := strings.Repeat("界", 101)
|
|
label := ToolInvocationLabel("bash", map[string]any{"command": command})
|
|
want := `Bash("` + strings.Repeat("界", 100) + `...")`
|
|
if label != want {
|
|
t.Fatalf("label = %q, want %q", label, want)
|
|
}
|
|
}
|
|
|
|
func TestToolInvocationLabelTruncatesLongPowerShellCommand(t *testing.T) {
|
|
command := strings.Repeat("a", 101)
|
|
label := ToolInvocationLabel("powershell", map[string]any{"command": command})
|
|
want := `PowerShell("` + strings.Repeat("a", 100) + `...")`
|
|
if label != want {
|
|
t.Fatalf("label = %q, want %q", label, want)
|
|
}
|
|
}
|