@@ -2,15 +2,14 @@ package jsonpatch
22
33import (
44"fmt"
5- "strings"
65"testing"
76)
87
98func mergePatch (doc , patch string ) string {
109out , err := MergePatch ([]byte (doc ), []byte (patch ))
1110
1211if err != nil {
13- panic (err )
12+ panic (fmt . Sprintf ( "%s: %s" , err , patch ) )
1413}
1514
1615return string (out )
@@ -166,8 +165,8 @@ var rfcTests = []struct {
166165{target : `{"a":[{"b":"c"}]}` , patch : `{"a":[1]}` , expected : `{"a":[1]}` },
167166{target : `["a","b"]` , patch : `["c","d"]` , expected : `["c","d"]` },
168167{target : `{"a":"b"}` , patch : `["c"]` , expected : `["c"]` },
169- // {target: `{"a":"foo"}`, patch: `null`, expected: `null`},
170- // {target: `{"a":"foo"}`, patch: `"bar"`, expected: `"bar"`},
168+ {target : `{"a":"foo"}` , patch : `null` , expected : `null` },
169+ {target : `{"a":"foo"}` , patch : `"bar"` , expected : `"bar"` },
171170{target : `{"e":null}` , patch : `{"a":1}` , expected : `{"a":1,"e":null}` },
172171{target : `[1,2]` , patch : `{"a":"b","c":null}` , expected : `{"a":"b"}` },
173172{target : `{}` , patch : `{"a":{"bb":{"ccc":null}}}` , expected : `{"a":{"bb":{}}}` },
@@ -183,33 +182,6 @@ func TestMergePatchRFCCases(t *testing.T) {
183182}
184183}
185184
186- var rfcFailTests = `
187- {"a":"foo"} | null
188- {"a":"foo"} | "bar"
189- `
190-
191- func TestMergePatchFailRFCCases (t * testing.T ) {
192- tests := strings .Split (rfcFailTests , "\n " )
193-
194- for _ , c := range tests {
195- if strings .TrimSpace (c ) == "" {
196- continue
197- }
198-
199- parts := strings .SplitN (c , "|" , 2 )
200-
201- doc := strings .TrimSpace (parts [0 ])
202- pat := strings .TrimSpace (parts [1 ])
203-
204- out , err := MergePatch ([]byte (doc ), []byte (pat ))
205-
206- if err != errBadJSONPatch {
207- t .Errorf ("error not returned properly: %s, %s" , err , string (out ))
208- }
209- }
210-
211- }
212-
213185func TestResembleJSONArray (t * testing.T ) {
214186testCases := []struct {
215187input []byte
0 commit comments