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

Method CompareContent

codegen/testutil/golden.go:90–123  ·  view source on GitHub ↗

CompareContent performs the golden file comparison

()

Source from the content-addressed store, hash-verified

88
89// CompareContent performs the golden file comparison
90func (g *GoldenFile) CompareContent() {
91 g.t.Helper()
92
93 if g.path == "" {
94 g.t.Fatal("golden file path not set")
95 }
96 if g.content == nil {
97 g.t.Fatal("content not set")
98 }
99
100 // Determine the full path
101 goldenPath := g.path
102 if !filepath.IsAbs(g.path) && g.basePath != "" {
103 goldenPath = filepath.Join(g.basePath, g.path)
104 }
105
106 // Prepare content
107 content := g.prepareContent()
108
109 // Check update mode
110 updateMode := g.update || isUpdateMode()
111
112 if updateMode {
113 g.updateFile(content, goldenPath)
114 return
115 }
116
117 // Check if file exists
118 if _, err := os.Stat(goldenPath); os.IsNotExist(err) {
119 g.t.Fatalf("golden file %q does not exist (run with -update to create)", goldenPath)
120 }
121
122 g.compareContent(content, goldenPath)
123}
124
125// Compare compares the actual content with the golden file content (legacy API)
126//

Callers 9

TestWithSubtestsFunction · 0.80
TestParallelUpdatesFunction · 0.80
CompareMethod · 0.80
CompareBytesMethod · 0.80
CompareOrUpdateGoldenFunction · 0.80
AssertFunction · 0.80
AssertStringFunction · 0.80
AssertJSONFunction · 0.80
AssertGoFunction · 0.80

Calls 4

prepareContentMethod · 0.95
updateFileMethod · 0.95
compareContentMethod · 0.95
isUpdateModeFunction · 0.85

Tested by 2

TestWithSubtestsFunction · 0.64
TestParallelUpdatesFunction · 0.64