MCPcopy Index your code
hub / github.com/bitfield/script / TestWriteFile_WritesInputToFileCreatingItIfNecessary

Function TestWriteFile_WritesInputToFileCreatingItIfNecessary

script_test.go:1703–1721  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1701}
1702
1703func TestWriteFile_WritesInputToFileCreatingItIfNecessary(t *testing.T) {
1704 t.Parallel()
1705 want := "Hello, world"
1706 path := t.TempDir() + "/" + t.Name()
1707 wrote, err := script.Echo(want).WriteFile(path)
1708 if err != nil {
1709 t.Fatal(err)
1710 }
1711 if int(wrote) != len(want) {
1712 t.Fatalf("want %d bytes written, got %d", len(want), int(wrote))
1713 }
1714 got, err := script.File(path).String()
1715 if err != nil {
1716 t.Fatal(err)
1717 }
1718 if got != want {
1719 t.Errorf("want %q, got %q", want, got)
1720 }
1721}
1722
1723// partialErrReader returns 1 and a non-EOF error on reading.
1724type partialErrReader struct{}

Callers

nothing calls this directly

Calls 4

EchoFunction · 0.92
FileFunction · 0.92
WriteFileMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…