Returns the full path to the file written.
(path string, contents string)
| 101 | |
| 102 | // Returns the full path to the file written. |
| 103 | func (f *TempDirFixture) WriteFile(path string, contents string) string { |
| 104 | fullPath := f.JoinPath(path) |
| 105 | base := filepath.Dir(fullPath) |
| 106 | err := os.MkdirAll(base, os.FileMode(0o777)) |
| 107 | if err != nil { |
| 108 | f.t.Fatal(err) |
| 109 | } |
| 110 | err = os.WriteFile(fullPath, []byte(contents), os.FileMode(0o777)) |
| 111 | if err != nil { |
| 112 | f.t.Fatal(err) |
| 113 | } |
| 114 | return fullPath |
| 115 | } |
| 116 | |
| 117 | // Returns the full path to the file written. |
| 118 | func (f *TempDirFixture) CopyFile(originalPath, newPath string) { |