Adding unit test to ensure patches are skipped for missing paths.

Signed-off-by: Sean Blong <seanblong@gmail.com>
This commit is contained in:
Sean Blong
2024-02-09 13:29:59 -08:00
parent cf460d51c3
commit 017b9a43e8
@@ -1650,6 +1650,35 @@ func TestResourceModifiers_conditional_patches(t *testing.T) {
wantErr: false,
wantObj: cmWithLabelAToB.DeepCopy(),
},
{
name: "missing condition path and skip patches",
rm: &ResourceModifiers{
Version: "v1",
ResourceModifierRules: []ResourceModifierRule{
{
Conditions: Conditions{
GroupResource: "*",
Namespaces: []string{"fake"},
Matches: []MatchRule{
{
Path: "/metadata/labels/a/b",
Value: "c",
},
},
},
MergePatches: []JSONMergePatch{
{
PatchData: `{"metadata":{"labels":{"a":"c"}}}`,
},
},
},
},
},
obj: cmWithLabelAToB.DeepCopy(),
groupResource: "configmaps",
wantErr: false,
wantObj: cmWithLabelAToB.DeepCopy(),
},
}
for _, tt := range tests {