(t *testing.T)
| 1475 | } |
| 1476 | |
| 1477 | func TestAppendFile_AppendsAllItsInputToSpecifiedFile(t *testing.T) { |
| 1478 | t.Parallel() |
| 1479 | orig := "Hello, world" |
| 1480 | path := t.TempDir() + "/" + t.Name() |
| 1481 | _, err := script.Echo(orig).WriteFile(path) |
| 1482 | if err != nil { |
| 1483 | t.Fatal(err) |
| 1484 | } |
| 1485 | extra := " and goodbye" |
| 1486 | wrote, err := script.Echo(extra).AppendFile(path) |
| 1487 | if err != nil { |
| 1488 | t.Fatal(err) |
| 1489 | } |
| 1490 | if int(wrote) != len(extra) { |
| 1491 | t.Fatalf("want %d bytes written, got %d", len(extra), int(wrote)) |
| 1492 | } |
| 1493 | // check file contains both contents |
| 1494 | got, err := script.File(path).String() |
| 1495 | if err != nil { |
| 1496 | t.Fatal(err) |
| 1497 | } |
| 1498 | if got != orig+extra { |
| 1499 | t.Errorf("want %q, got %q", orig+extra, got) |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | func TestAppendFile_ReturnsBytesWrittenAndErrorGivenReadErrorOnPipe(t *testing.T) { |
| 1504 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…