MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestExecuteWriteFileWrapsResult

Function TestExecuteWriteFileWrapsResult

internal/tools/write_test.go:80–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestExecuteWriteFileWrapsResult(t *testing.T) {
81 dir := t.TempDir()
82 path := filepath.Join(dir, "out.txt")
83 call := chmctx.ToolCall{
84 ID: "call_w",
85 Name: "write_file",
86 Arguments: map[string]any{
87 "path": path,
88 "content": "hello",
89 },
90 }
91 msg := Execute(context.Background(), call)
92 if msg.Role != chmctx.RoleTool || msg.ToolCallID != "call_w" || msg.ToolName != "write_file" {
93 t.Fatalf("bad message: %+v", msg)
94 }
95 if !strings.Contains(msg.Content, "wrote 5 bytes") {
96 t.Fatalf("content missing: %q", msg.Content)
97 }
98 got, _ := os.ReadFile(path)
99 if string(got) != "hello" {
100 t.Fatalf("file content wrong: %q", got)
101 }
102}
103
104// TestExecuteWriteFileRefusesMissingContent: valid-JSON args with no string
105// "content" ({"path": ...} alone, or "content": null) must not decode to ""

Callers

nothing calls this directly

Calls 1

ExecuteFunction · 0.85

Tested by

no test coverage detected