Skip to content

Commit 089ffda

Browse files
committed
Fix DatacenterID immutability test
The test was failing because it didn't refresh the object from the server before attempting to update it. The CEL validation rule needs to compare self with oldSelf, which requires the object to be fetched first to have the correct resource version and state. Add Get call before Update to ensure the validation rule can properly check immutability.
1 parent d81ebc5 commit 089ffda

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

api/v1alpha1/ionoscloudmachine_types_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ var _ = Describe("IonosCloudMachine Tests", func() {
134134
m := defaultMachine()
135135
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
136136
Expect(m.Spec.DatacenterID).To(Equal(defaultMachine().Spec.DatacenterID))
137+
// Get the object from the server to ensure we have the latest version
138+
Expect(k8sClient.Get(context.Background(), client.ObjectKey{Name: m.Name, Namespace: m.Namespace}, m)).To(Succeed())
137139
m.Spec.DatacenterID = "6ded8c5f-8df2-46ef-b4ce-61833daf0961"
138140
Expect(k8sClient.Update(context.Background(), m)).ToNot(Succeed())
139141
})

0 commit comments

Comments
 (0)