MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestWriteFileHappy

Function TestWriteFileHappy

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

Source from the content-addressed store, hash-verified

11)
12
13func TestWriteFileHappy(t *testing.T) {
14 dir := t.TempDir()
15 path := filepath.Join(dir, "hello.txt")
16 content := "line one\nline two with 'quotes' and $dollar and `backticks`\n"
17 s := WriteFile(path, content)
18 if !strings.Contains(s, "wrote") || !strings.Contains(s, "hello.txt") {
19 t.Fatalf("status wrong: %q", s)
20 }
21 got, err := os.ReadFile(path)
22 if err != nil {
23 t.Fatalf("readback: %v", err)
24 }
25 if string(got) != content {
26 t.Fatalf("content mismatch: %q", got)
27 }
28}
29
30func TestWriteFileCreatesParentDirs(t *testing.T) {
31 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

WriteFileFunction · 0.85

Tested by

no test coverage detected