diff --git a/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go b/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go index 88692ad0612..53d5db5a0ad 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go @@ -1208,6 +1208,52 @@ testCases: `) var strategicMergePatchRawTestCases = []StrategicMergePatchRawTestCase{ + { + Description: "nested patch merge with empty list", + StrategicMergePatchRawTestCaseData: StrategicMergePatchRawTestCaseData{ + Original: []byte(` +name: hi +`), + Current: []byte(` +name: hi +mergingList: +- name: hello2 +`), + Modified: []byte(` +name: hi +mergingList: +- name: hello +- $patch: delete + name: doesntexist +`), + TwoWay: []byte(` +mergingList: +- name: hello +- $patch: delete + name: doesntexist +`), + ThreeWay: []byte(` +$setElementOrder/mergingList: +- name: hello +- name: doesntexist +mergingList: +- name: hello +- $patch: delete + name: doesntexist +`), + TwoWayResult: []byte(` +name: hi +mergingList: +- name: hello +`), + Result: []byte(` +name: hi +mergingList: +- name: hello +- name: hello2 +`), + }, + }, { Description: "delete items in lists of scalars", StrategicMergePatchRawTestCaseData: StrategicMergePatchRawTestCaseData{