updateFile writes content to the golden file
(content []byte, goldenPath string)
| 176 | |
| 177 | // updateFile writes content to the golden file |
| 178 | func (g *GoldenFile) updateFile(content []byte, goldenPath string) { |
| 179 | g.t.Helper() |
| 180 | |
| 181 | // Create directory if it doesn't exist |
| 182 | dir := filepath.Dir(goldenPath) |
| 183 | if err := os.MkdirAll(dir, 0750); err != nil { |
| 184 | g.t.Fatalf("failed to create golden file directory %q: %v", dir, err) |
| 185 | } |
| 186 | |
| 187 | // Write the golden file |
| 188 | if err := os.WriteFile(goldenPath, content, 0644); err != nil { |
| 189 | g.t.Fatalf("failed to update golden file %q: %v", goldenPath, err) |
| 190 | } |
| 191 | |
| 192 | g.t.Logf("Updated golden file: %s", goldenPath) |
| 193 | } |
| 194 | |
| 195 | // compareContent reads the golden file and compares with content |
| 196 | func (g *GoldenFile) compareContent(content []byte, goldenPath string) { |