Fix premature return

pull/6/head
Shimin Guo 2017-07-29 09:29:23 +00:00
parent e3c2482959
commit aa1d47a3c6
2 changed files with 76 additions and 4 deletions

View File

@ -1138,7 +1138,7 @@ func mergePatchIntoOriginal(original, patch map[string]interface{}, t reflect.Ty
return err
}
case !foundOriginal && !foundPatch:
return nil
continue
}
// Split all items into patch items and server-only items and then enforce the order.

View File

@ -5966,6 +5966,75 @@ retainKeysMergingList:
retainKeysMergingList:
- name: bar
- name: foo
`),
},
},
{
Description: "delete and reorder in one list, reorder in another",
StrategicMergePatchRawTestCaseData: StrategicMergePatchRawTestCaseData{
Original: []byte(`
mergingList:
- name: a
value: a
- name: b
value: b
mergeItemPtr:
- name: c
value: c
- name: d
value: d
`),
Current: []byte(`
mergingList:
- name: a
value: a
- name: b
value: b
mergeItemPtr:
- name: c
value: c
- name: d
value: d
`),
Modified: []byte(`
mergingList:
- name: b
value: b
mergeItemPtr:
- name: d
value: d
- name: c
value: c
`),
TwoWay: []byte(`
$setElementOrder/mergingList:
- name: b
$setElementOrder/mergeItemPtr:
- name: d
- name: c
mergingList:
- $patch: delete
name: a
`),
ThreeWay: []byte(`
$setElementOrder/mergingList:
- name: b
$setElementOrder/mergeItemPtr:
- name: d
- name: c
mergingList:
- $patch: delete
name: a
`),
Result: []byte(`
mergingList:
- name: b
value: b
mergeItemPtr:
- name: d
value: d
- name: c
value: c
`),
},
},
@ -5993,9 +6062,12 @@ func TestStrategicMergePatch(t *testing.T) {
testThreeWayPatch(t, c)
}
for _, c := range strategicMergePatchRawTestCases {
testTwoWayPatchForRawTestCase(t, c)
testThreeWayPatchForRawTestCase(t, c)
// run multiple times to exercise different map traversal orders
for i := 0; i < 10; i++ {
for _, c := range strategicMergePatchRawTestCases {
testTwoWayPatchForRawTestCase(t, c)
testThreeWayPatchForRawTestCase(t, c)
}
}
}