MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / assertJSON

Function assertJSON

internal/controller/runtime/patch_test.go:16–41  ·  view source on GitHub ↗
(t testing.TB, expected any, actual []byte)

Source from the content-addressed store, hash-verified

14)
15
16func assertJSON(t testing.TB, expected any, actual []byte) {
17 t.Helper()
18
19 var e, a any
20 var err error
21
22 if b, ok := expected.([]byte); ok {
23 err = json.Unmarshal(b, &e)
24 } else if s, ok := expected.(string); ok {
25 err = json.Unmarshal([]byte(s), &e)
26 } else {
27 t.Fatalf("bug in test: unexpected type %T", expected)
28 }
29
30 if err != nil {
31 t.Fatalf("bug in test: %v", err)
32 }
33
34 if err = json.Unmarshal(actual, &a); err != nil {
35 t.Fatal(err)
36 }
37
38 if !reflect.DeepEqual(e, a) {
39 t.Errorf("\n--- Expected\n+++ Actual\n- %#v\n+ %#v", e, a)
40 }
41}
42
43func TestEscapeJSONPointer(t *testing.T) {
44 t.Parallel()

Callers 3

TestJSON6902Function · 0.85
TestMerge7386Function · 0.85
TestMerge7386EquivalenceFunction · 0.85

Calls 1

HelperMethod · 0.80

Tested by

no test coverage detected