| 96 | } |
| 97 | |
| 98 | func (tp *temp) Save(value string, key ...string) string { |
| 99 | tp.t.Helper() |
| 100 | |
| 101 | tp.Dir(key[:len(key)-1]...) |
| 102 | |
| 103 | pth := filepath.Join(append([]string{tp.tempDir}, key...)...) |
| 104 | |
| 105 | err := os.WriteFile( |
| 106 | pth, |
| 107 | []byte(value), |
| 108 | FilePermissionsDefault, |
| 109 | ) |
| 110 | |
| 111 | assertive.ErrorIsNil( |
| 112 | assertive.WithSilentSuccess(tp.t), |
| 113 | err, |
| 114 | fmt.Sprintf("Saving file %q must succeed", pth), |
| 115 | ) |
| 116 | |
| 117 | return pth |
| 118 | } |
| 119 | |
| 120 | func (tp *temp) SaveToWriter(writer func(file io.Writer) error, key ...string) string { |
| 121 | tp.t.Helper() |