From bb83b4a815a04538f5839aa853dd3e602e7000bb Mon Sep 17 00:00:00 2001 From: Yash Raj Date: Mon, 15 Jul 2024 11:14:11 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1Add=20few=20more=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hcloudmachinetemplate_controller_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/controllers/hcloudmachinetemplate_controller_test.go b/controllers/hcloudmachinetemplate_controller_test.go index 9bda55d1c..e897498a1 100644 --- a/controllers/hcloudmachinetemplate_controller_test.go +++ b/controllers/hcloudmachinetemplate_controller_test.go @@ -289,10 +289,21 @@ var _ = Describe("HCloudMachineTemplateReconciler", func() { It("should prevent updating Image name", func() { Expect(testEnv.Get(ctx, key, machineTemplate)).To(Succeed()) - hcloudMachineTemplate.Spec.Template.Spec.Type = "cpx32" + hcloudMachineTemplate.Spec.Template.Spec.ImageName = "fedora-control-plane" + Expect(testEnv.Client.Update(ctx, hcloudMachineTemplate)).ToNot(Succeed()) + + }) + It("should prevent updating SSHKey", func() { + Expect(testEnv.Get(ctx, key, machineTemplate)).To(Succeed()) + + hcloudMachineTemplate.Spec.Template.Spec.SSHKeys = []infrav1.SSHKey{{Name: "ssh-key-1"}} Expect(testEnv.Client.Update(ctx, hcloudMachineTemplate)).ToNot(Succeed()) - hcloudMachineTemplate.Spec.Template.Spec.ImageName = "fedor-control-plane" + }) + It("should prevent updating PlacementGroups", func() { + Expect(testEnv.Get(ctx, key, machineTemplate)).To(Succeed()) + + hcloudMachineTemplate.Spec.Template.Spec.PlacementGroupName = createPlacementGroupName("placement-group-1") Expect(testEnv.Client.Update(ctx, hcloudMachineTemplate)).ToNot(Succeed()) }) @@ -314,3 +325,7 @@ var _ = Describe("HCloudMachineTemplateReconciler", func() { }) }) + +func createPlacementGroupName(name string) *string { + return &name +}