Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
fix: unit tests for patching kubeadmconfigtemplate with containerd re…
Browse files Browse the repository at this point in the history
…start
  • Loading branch information
supershal committed Apr 1, 2024
1 parent 853f918 commit cfe0f05
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/handlers/generic/mutation/containerdrestart/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/patches/selectors"
)

type globalMirrorPatchHandler struct{}
type containerdRestartPatchHandler struct{}

func NewPatch() *globalMirrorPatchHandler {
return &globalMirrorPatchHandler{}
func NewPatch() *containerdRestartPatchHandler {
return &containerdRestartPatchHandler{}
}

func (h *globalMirrorPatchHandler) Mutate(
func (h *containerdRestartPatchHandler) Mutate(
ctx context.Context,
obj *unstructured.Unstructured,
vars map[string]apiextensionsv1.JSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/onsi/gomega"
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"

"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation"
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
Expand Down Expand Up @@ -46,12 +47,22 @@ func TestGeneratePatches(
},
},
capitest.PatchTestDef{
Name: "restart script and command added to worker node kubeadm config template",
RequestItem: request.NewKubeadmControlPlaneTemplateRequestItem(""),
Name: "restart script and command added to worker node kubeadm config template",
Vars: []runtimehooksv1.Variable{
capitest.VariableWithValue(
"builtin",
map[string]any{
"machineDeployment": map[string]any{
"class": "*",
},
},
),
},
RequestItem: request.NewKubeadmConfigTemplateRequestItem(""),
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{
{
Operation: "add",
Path: "/spec/template/spec/kubeadmConfigSpec/files",
Path: "/spec/template/spec/files",
ValueMatcher: gomega.ContainElements(
gomega.HaveKeyWithValue(
"path", containerdrestart.ContainerdRestartScriptOnRemote,
Expand All @@ -60,7 +71,7 @@ func TestGeneratePatches(
},
{
Operation: "add",
Path: "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands",
Path: "/spec/template/spec/preKubeadmCommands",
ValueMatcher: gomega.ContainElements(
containerdrestart.ContainerdRestartScriptOnRemoteCommand,
),
Expand Down

0 comments on commit cfe0f05

Please sign in to comment.