Skip to content

Commit

Permalink
Fix known broken case
Browse files Browse the repository at this point in the history
Signed-off-by: John Howard <[email protected]>
  • Loading branch information
howardjohn committed May 16, 2023
1 parent c616a48 commit e0f6c24
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions v2/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func FuzzCreatePatch(f *testing.F) {
}

func checkFuzz(t *testing.T, src, dst []byte) {
t.Logf("Test: %v -> %v", string(src), string(dst))
patch, err := jsonpatch.CreatePatch(src, dst)
if err != nil {
// Ok to error, src or dst may be invalid
Expand All @@ -37,9 +38,17 @@ func checkFuzz(t *testing.T, src, dst []byte) {
return
}

for _, p := range patch {
if p.Path == "" {
// json-patch doesn't handle this properly, but it is valid
return
}
}

data, err := json.Marshal(patch)
assert.Nil(t, err)

t.Logf("Applying patch %v", string(data))
p2, err := jp.DecodePatch(data)
assert.Nil(t, err)

Expand Down

0 comments on commit e0f6c24

Please sign in to comment.