MCPcopy Create free account
hub / github.com/goadesign/goa / updateFile

Method updateFile

codegen/testutil/golden.go:178–193  ·  view source on GitHub ↗

updateFile writes content to the golden file

(content []byte, goldenPath string)

Source from the content-addressed store, hash-verified

176
177// updateFile writes content to the golden file
178func (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
196func (g *GoldenFile) compareContent(content []byte, goldenPath string) {

Callers 1

CompareContentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected