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)
| 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. |
| 68 | func 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 | |
| 80 | func TestExecuteWriteFileWrapsResult(t *testing.T) { |
| 81 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected