From 0149c1f8b315d704d6d80c00861526e2899001e5 Mon Sep 17 00:00:00 2001 From: Alexander Zielenski Date: Wed, 11 Oct 2023 15:45:48 -0700 Subject: [PATCH] test: few more correlatedobject test cases --- .../apiserver/pkg/cel/common/equality_test.go | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go b/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go index cf8eadcaaca..c1129efa896 100644 --- a/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go +++ b/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go @@ -238,6 +238,64 @@ func TestCorrelation(t *testing.T) { NewValue: "b", OldValue: "oldB", }, + { + Name: "Replaced Key In Old Object", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: map[string]interface{}{ + "b": "a", + }, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: map[string]interface{}{"b": "a"}, + }, + { + Name: "Added Key In Old Object", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: map[string]interface{}{}, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: map[string]interface{}{}, + }, + { + Name: "Changed list to map", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: []interface{}{"a", "b"}, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: []interface{}{"a", "b"}, + }, + { + Name: "Changed string to map", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: "a string", + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: "a string", + }, { Name: "Map list type", RootObject: mustUnstructured(`