kubeadm: add unit tests for patching a "kubeletconfiguration" target

This commit is contained in:
Lubomir I. Ivanov 2022-06-06 17:57:56 +03:00
parent 85fb6b01f8
commit c3c9fb8608

View File

@ -26,7 +26,7 @@ import (
"github.com/pkg/errors"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
)
@ -35,6 +35,7 @@ var testKnownTargets = []string{
"kube-apiserver",
"kube-controller-manager",
"kube-scheduler",
"kubeletconfiguration",
}
const testDirPattern = "patch-files"
@ -312,6 +313,21 @@ func TestGetPatchManagerForPath(t *testing.T) {
},
},
},
{
name: "valid: kubeletconfiguration target is patched with json patch",
patchTarget: &PatchTarget{
Name: "kubeletconfiguration",
StrategicMergePatchObject: nil,
Data: []byte("foo: bar\n"),
},
expectedData: []byte(`{"foo":"zzz"}`),
files: []*file{
{
name: "kubeletconfiguration+json.json",
data: `[{"op": "replace", "path": "/foo", "value": "zzz"}]`,
},
},
},
{
name: "valid: kube-apiserver target is patched with strategic merge patch",
patchTarget: &PatchTarget{