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

Function TestWriteFileWriteErrorWhenTargetIsDir

internal/tools/write_test.go:68–78  ·  view source on GitHub ↗

TestWriteFileWriteErrorWhenTargetIsDir checks the (write error) branch: writing to an existing directory fails at os.WriteFile, and the error must come back in the output string. A directory target is root-safe, as above.

(t *testing.T)

Source from the content-addressed store, hash-verified

66// writing to an existing directory fails at os.WriteFile, and the error must
67// come back in the output string. A directory target is root-safe, as above.
68func TestWriteFileWriteErrorWhenTargetIsDir(t *testing.T) {
69 dir := t.TempDir()
70 target := filepath.Join(dir, "imadir")
71 if err := os.Mkdir(target, 0o755); err != nil {
72 t.Fatal(err)
73 }
74 got := WriteFile(target, "data")
75 if !strings.HasPrefix(got, "(write error:") {
76 t.Fatalf("expected (write error: ...) string, got %q", got)
77 }
78}
79
80func TestExecuteWriteFileWrapsResult(t *testing.T) {
81 dir := t.TempDir()

Callers

nothing calls this directly

Calls 1

WriteFileFunction · 0.85

Tested by

no test coverage detected