From ceaf9b9d16a8f2a547b4557ad67fb7d70f3b79ea Mon Sep 17 00:00:00 2001 From: pacoxu Date: Fri, 4 Jun 2021 13:46:19 +0800 Subject: [PATCH] add ut for preventing dropping null from arrays Signed-off-by: pacoxu --- .../pkg/util/jsonmergepatch/patch_test.go | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch/patch_test.go b/staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch/patch_test.go index 25435206570..c3e363ac2fb 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch/patch_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch/patch_test.go @@ -602,6 +602,57 @@ testCases: - false - b: 1 bar: 0 + - description: patch array with nil + original: + foo: + - a: true + - null + - false + bar: [] + drop: + - 1 + modified: + foo: + - 1 + - false + - b: 1 + bar: + - c + - null + - null + - a + drop: + - null + current: + foo: + - a: true + - 2 + - false + bar: + - c + - null + - null + - a + drop: + threeWay: + foo: + - 1 + - false + - b: 1 + drop: + - null + result: + foo: + - 1 + - false + - b: 1 + drop: + - null + bar: + - c + - null + - null + - a `) func TestCreateThreeWayJSONMergePatch(t *testing.T) {