AssertJSON compares JSON content with proper formatting
(t testing.TB, goldenPath string, got []byte)
| 274 | |
| 275 | // AssertJSON compares JSON content with proper formatting |
| 276 | func 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 |
| 289 | func AssertGo(t testing.TB, goldenPath string, got string) { |