MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / compareJSONBodies

Function compareJSONBodies

lib/workertypes/types_test.go:453–468  ·  view source on GitHub ↗
(t *testing.T, actualBody, expectedBody []byte)

Source from the content-addressed store, hash-verified

451
452 compareJSONBodies(t, got, []byte(tc.expected))
453 })
454 }
455}
456
457func compareJSONBodies(t *testing.T, actualBody, expectedBody []byte) {
458 t.Helper()
459 var actualObj, expectedObj any
460 err := json.Unmarshal(actualBody, &actualObj)
461 if err != nil {
462 t.Fatal("failed to parse json from actual response")
463 }
464 err = json.Unmarshal(expectedBody, &expectedObj)
465 if err != nil {
466 t.Fatal("failed to parse json from expected response")
467 }
468
469 if diff := cmp.Diff(expectedObj, actualObj); diff != "" {
470 t.Errorf("JSON mismatch (-want +got):\n%s", diff)
471 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected