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

Function AssertJSON

codegen/testutil/golden.go:276–286  ·  view source on GitHub ↗

AssertJSON compares JSON content with proper formatting

(t testing.TB, goldenPath string, got []byte)

Source from the content-addressed store, hash-verified

274
275// AssertJSON compares JSON content with proper formatting
276func AssertJSON(t testing.TB, goldenPath string, got []byte) {
277 t.Helper()
278 gf := &GoldenFile{t: t, basePath: ""}
279 var v any
280 if err := json.Unmarshal(got, &v); err == nil {
281 if formatted, err := json.MarshalIndent(v, "", " "); err == nil {
282 got = formatted
283 }
284 }
285 gf.Content(got).Path(goldenPath).CompareContent()
286}
287
288// AssertGo compares Go source code with proper formatting
289func AssertGo(t testing.TB, goldenPath string, got string) {

Callers 5

TestSectionsFunction · 0.92
TestValidationsFunction · 0.92
TestExtensionsFunction · 0.92
TestFilesFunction · 0.92

Calls 3

ContentMethod · 0.95
CompareContentMethod · 0.80
PathMethod · 0.80

Tested by 5

TestSectionsFunction · 0.74
TestValidationsFunction · 0.74
TestExtensionsFunction · 0.74
TestFilesFunction · 0.74