TestEditFileRefusesNonRegular: edit_file reads the target first, so it needs the same guard as read_file.
(t *testing.T)
| 67 | // TestEditFileRefusesNonRegular: edit_file reads the target first, so it needs |
| 68 | // the same guard as read_file. |
| 69 | func TestEditFileRefusesNonRegular(t *testing.T) { |
| 70 | path := mkfifo(t) |
| 71 | done := make(chan string, 1) |
| 72 | go func() { done <- EditFile(path, "a", "b") }() |
| 73 | select { |
| 74 | case got := <-done: |
| 75 | if !strings.Contains(got, "not a regular file") { |
| 76 | t.Fatalf("want a not-a-regular-file refusal, got %q", got) |
| 77 | } |
| 78 | case <-timeoutC(t): |
| 79 | t.Fatal("EditFile blocked on the FIFO instead of refusing") |
| 80 | } |
| 81 | } |