Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package tools
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSanitizeSandboxFileCallArgsStripsWriteBody(t *testing.T) {
|
|
content := strings.Repeat("x\n", 15)
|
|
out := SanitizeSandboxFileCallArgs(ToolWriteSandboxFile, map[string]any{
|
|
"path": "/workspace/output/a.py",
|
|
"content": content,
|
|
"mode": "overwrite",
|
|
})
|
|
if _, ok := out["content"]; ok {
|
|
t.Fatal("write progress must not carry the file body")
|
|
}
|
|
if out["path"] != "/workspace/output/a.py" {
|
|
t.Fatalf("path = %v", out["path"])
|
|
}
|
|
if out["added_lines"] != 15 {
|
|
t.Fatalf("added_lines = %v, want 15", out["added_lines"])
|
|
}
|
|
if out["removed_lines"] != 0 {
|
|
t.Fatalf("removed_lines = %v", out["removed_lines"])
|
|
}
|
|
preview, _ := out["preview"].(string)
|
|
if strings.Count(preview, "\n")+1 != sandboxFilePreviewMaxLines {
|
|
t.Fatalf("preview lines = %q", preview)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeSandboxFileCallArgsStripsEditBodies(t *testing.T) {
|
|
out := SanitizeSandboxFileCallArgs(ToolEditSandboxFile, map[string]any{
|
|
"path": "/workspace/a.py",
|
|
"edits": []any{
|
|
map[string]any{"old_string": "a\nb\n", "new_string": "a\nb\nc\n"},
|
|
},
|
|
})
|
|
if _, ok := out["edits"]; ok {
|
|
t.Fatal("edit progress must not carry edits")
|
|
}
|
|
if out["removed_lines"] != 2 {
|
|
t.Fatalf("removed_lines = %v, want 2", out["removed_lines"])
|
|
}
|
|
if out["added_lines"] != 3 {
|
|
t.Fatalf("added_lines = %v, want 3", out["added_lines"])
|
|
}
|
|
}
|
|
|
|
func TestSanitizeSandboxFileCallArgsLeavesOtherToolsAlone(t *testing.T) {
|
|
args := map[string]any{"command": "ls"}
|
|
out := SanitizeSandboxFileCallArgs(ToolShellExec, args)
|
|
if out["command"] != "ls" {
|
|
t.Fatalf("unrelated args = %#v", out)
|
|
}
|
|
}
|