@@ -184,10 +184,29 @@ var _ = Describe("JSONPatch", func() {
184
184
// add
185
185
testPatchWithExpected ([]int {1 , 2 , 3 }, []int {1 , 3 }, []int {1 , 3 , 2 }, jsonpatch .IgnoreSliceOrder ())
186
186
testPatchWithExpected ([]int {1 , 2 , 3 }, []int {1 , 2 }, []int {1 , 2 , 3 }, jsonpatch .IgnoreSliceOrder ())
187
+ // no change
188
+ testPatchWithExpected ([]int {3 , 2 , 1 }, []int {1 , 2 , 3 }, []int {1 , 2 , 3 }, jsonpatch .IgnoreSliceOrder ())
189
+ testPatchWithExpected ([]int {1 , 2 , 3 }, []int {3 , 2 , 1 }, []int {3 , 2 , 1 }, jsonpatch .IgnoreSliceOrder ())
187
190
// remove
188
191
testPatchWithExpected ([]int {3 , 1 }, []int {1 , 2 , 3 }, []int {1 , 3 }, jsonpatch .IgnoreSliceOrder ())
189
192
testPatchWithExpected ([]int {3 , 2 }, []int {1 , 2 , 3 }, []int {2 , 3 }, jsonpatch .IgnoreSliceOrder ())
190
193
})
194
+ It ("uint slice ignore order" , func () {
195
+ // add
196
+ testPatchWithExpected ([]uint {1 , 2 , 3 }, []uint {1 , 3 }, []uint {1 , 3 , 2 }, jsonpatch .IgnoreSliceOrder ())
197
+ testPatchWithExpected ([]uint16 {1 , 2 , 3 }, []uint16 {1 , 2 }, []uint16 {1 , 2 , 3 }, jsonpatch .IgnoreSliceOrder ())
198
+ // remove
199
+ testPatchWithExpected ([]uint32 {3 , 1 }, []uint32 {1 , 2 , 3 }, []uint32 {1 , 3 }, jsonpatch .IgnoreSliceOrder ())
200
+ testPatchWithExpected ([]uint64 {3 , 2 }, []uint64 {1 , 2 , 3 }, []uint64 {2 , 3 }, jsonpatch .IgnoreSliceOrder ())
201
+ })
202
+ It ("bool slice ignore order" , func () {
203
+ // add
204
+ testPatchWithExpected ([]bool {true , false }, []bool {false }, []bool {false , true }, jsonpatch .IgnoreSliceOrder ())
205
+ testPatchWithExpected ([]bool {true , false }, []bool {true }, []bool {true , false }, jsonpatch .IgnoreSliceOrder ())
206
+ // remove
207
+ testPatchWithExpected ([]bool {true }, []bool {false , true }, []bool {true }, jsonpatch .IgnoreSliceOrder ())
208
+ testPatchWithExpected ([]bool {true }, []bool {true , false }, []bool {true }, jsonpatch .IgnoreSliceOrder ())
209
+ })
191
210
It ("ptr slice ignore order" , func () {
192
211
// add
193
212
testPatchWithExpected (D {PtrSliceWithKey : []* B {{Str : "key1" }}}, D {}, D {PtrSliceWithKey : []* B {{Str : "key1" }}}, jsonpatch .IgnoreSliceOrderWithPattern ([]jsonpatch.IgnorePattern {{"/ptrWithKey" , "str" }}))
@@ -381,13 +400,15 @@ func testPatch(modified, current interface{}) {
381
400
382
401
bytes , changes , err := jsonpatch .CreateJSONPatch (modified , current )
383
402
Ω (err ).ShouldNot (HaveOccurred ())
384
- if string ( bytes ) == "" {
403
+ if bytes . Empty () {
385
404
Ω (currentJSON ).Should (MatchJSON (modifiedJSON ))
386
405
Ω (changes ).Should (Equal (0 ))
406
+ Ω (bytes .String ()).Should (Equal ("" ))
387
407
388
408
return
389
409
}
390
410
411
+ Ω (bytes .String ()).ShouldNot (Equal ("" ))
391
412
jsonPatch , err := jsonpatch2 .DecodePatch (bytes )
392
413
Ω (err ).ShouldNot (HaveOccurred ())
393
414
patchedJSON , err := jsonPatch .Apply (currentJSON )
@@ -405,13 +426,15 @@ func testPatchWithExpected(modified, current, expected interface{}, options ...j
405
426
406
427
bytes , changes , err := jsonpatch .CreateJSONPatch (modified , current , options ... )
407
428
Ω (err ).ShouldNot (HaveOccurred ())
408
- if string ( bytes ) == "" {
429
+ if bytes . Empty () {
409
430
Ω (currentJSON ).Should (MatchJSON (expectedJSON ))
410
431
Ω (changes ).Should (Equal (0 ))
432
+ Ω (bytes .String ()).Should (Equal ("" ))
411
433
412
434
return
413
435
}
414
436
437
+ Ω (bytes .String ()).ShouldNot (Equal ("" ))
415
438
jsonPatch , err := jsonpatch2 .DecodePatch (bytes )
416
439
Ω (err ).ShouldNot (HaveOccurred ())
417
440
patchedJSON , err := jsonPatch .Apply (currentJSON )
0 commit comments