@@ -18,11 +18,11 @@ package v1alpha2
1818
1919import (
2020 "context"
21- // "strconv"
21+ "strconv"
2222
2323 . "github.com/onsi/ginkgo/v2"
2424 . "github.com/onsi/gomega"
25- // corev1 "k8s.io/api/core/v1"
25+ corev1 "k8s.io/api/core/v1"
2626 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727 "k8s.io/utils/ptr"
2828 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -60,7 +60,6 @@ var _ = Describe("ProxmoxMachine Test", func() {
6060 })
6161
6262 Context ("VirtualMachineCloneSpec" , func () {
63- /* caught by validation
6463 It ("Should not allow specifying format if full clone is disabled" , func () {
6564 dm := defaultMachine ()
6665 dm .Spec .Format = ptr .To (TargetStorageFormatRaw )
@@ -98,16 +97,16 @@ var _ = Describe("ProxmoxMachine Test", func() {
9897 dm := defaultMachine ()
9998 dm .Spec .TemplateSelector = & TemplateSelector {MatchTags : []string {"test" }}
10099 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("must define either a SourceNode with a TemplateID or a TemplateSelector" )))
101- })*/
100+ })
102101
103- /* It("Should not allow specifying TemplateSelector with empty MatchTags", func() {
102+ It ("Should not allow specifying TemplateSelector with empty MatchTags" , func () {
104103 dm := defaultMachine ()
105104 dm .Spec .TemplateSelector = & TemplateSelector {MatchTags : []string {}}
106105
107- Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should have at least 1 items ")))
108- })*/
106+ Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("spec.templateSelector.matchTags: Required value " )))
107+ })
109108
110- /* It("Should only allow valid MatchTags", func() {
109+ It ("Should only allow valid MatchTags" , func () {
111110 testCases := []struct {
112111 tag string
113112 expectErrror bool
@@ -156,16 +155,16 @@ var _ = Describe("ProxmoxMachine Test", func() {
156155 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring (testCase .errorMessage )))
157156 }
158157 }
159- })*/
158+ })
160159 })
161160
162161 Context ("Disks" , func () {
163- /* It("Should not allow updates to disks", func() {
162+ It ("Should not allow updates to disks" , func () {
164163 dm := defaultMachine ()
165164 Expect (k8sClient .Create (context .Background (), dm )).To (Succeed ())
166165 dm .Spec .Disks .BootVolume .SizeGB = 50
167166 Expect (k8sClient .Update (context .Background (), dm )).Should (MatchError (ContainSubstring ("is immutable" )))
168- })*/
167+ })
169168
170169 It ("Should not allow negative or less than minimum values" , func () {
171170 dm := defaultMachine ()
@@ -179,7 +178,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
179178 })
180179
181180 Context ("Network" , func () {
182- /* It("Should set default bridge", func() {
181+ It ("Should set default bridge" , func () {
183182 dm := defaultMachine ()
184183 dm .Spec .Network = & NetworkSpec {
185184 NetworkDevices : []NetworkDevice {{
@@ -188,15 +187,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
188187 }
189188
190189 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("should be at least 1 chars long" )))
191- })*/
190+ })
192191
193- /* It("Should not allow net0 in additional network devices", func() {
192+ It ("Should not allow net0 in additional network devices" , func () {
194193 dm := defaultMachine ()
195194 dm .Spec .Network = & NetworkSpec {
196195 NetworkDevices : []NetworkDevice {{
197196 Bridge : ptr .To ("vmbr0" ),
198197 }, {
199- Name: "net0",
198+ Name : ptr . To ( "net0" ) ,
200199 InterfaceConfig : InterfaceConfig {
201200 IPPoolRef : []corev1.TypedLocalObjectReference {{
202201 APIGroup : ptr .To ("ipam.cluster.x-k8s.io" ),
@@ -207,15 +206,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
207206 }},
208207 }
209208
210- Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("should be at least 1 chars long ")))
211- })*/
209+ Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("spec.network.networkDevices[1]: Duplicate value " )))
210+ })
212211
213- /* It("Should only allow IPAM pool resources in IPPoolRef apiGroup", func() {
212+ It ("Should only allow IPAM pool resources in IPPoolRef apiGroup" , func () {
214213 dm := defaultMachine ()
215214 dm .Spec .Network = & NetworkSpec {
216215 NetworkDevices : []NetworkDevice {{
217216 Bridge : ptr .To ("vmbr0" ),
218- Name: "net1",
217+ Name : ptr . To ( "net1" ) ,
219218 InterfaceConfig : InterfaceConfig {
220219 IPPoolRef : []corev1.TypedLocalObjectReference {{
221220 APIGroup : ptr .To ("apps" ),
@@ -232,7 +231,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
232231 dm .Spec .Network = & NetworkSpec {
233232 NetworkDevices : []NetworkDevice {{
234233 Bridge : ptr .To ("vmbr0" ),
235- Name: "net1",
234+ Name : ptr . To ( "net1" ) ,
236235 InterfaceConfig : InterfaceConfig {
237236 IPPoolRef : []corev1.TypedLocalObjectReference {{
238237 APIGroup : ptr .To ("ipam.cluster.x-k8s.io" ),
@@ -269,7 +268,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
269268 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("invalid MTU value" )))
270269 })
271270
272- It("Should only allow VRFS with a non kernel routing table ", func() {
271+ /* It("Should only allow VRFS with a non kernel routing table ", func() {
273272 dm := defaultMachine()
274273 dm.Spec.Network = &NetworkSpec{
275274 VirtualNetworkDevices: VirtualNetworkDevices{
@@ -281,9 +280,9 @@ var _ = Describe("ProxmoxMachine Test", func() {
281280 }
282281
283282 Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Cowardly refusing to insert l3mdev rules into kernel tables")))
284- })
283+ })*/
285284
286- It("Should only allow non kernel FIB rule priority", func() {
285+ /* It("Should only allow non kernel FIB rule priority", func() {
287286 dm := defaultMachine()
288287 dm.Spec.Network = &NetworkSpec{
289288 VirtualNetworkDevices: VirtualNetworkDevices{
@@ -292,7 +291,7 @@ var _ = Describe("ProxmoxMachine Test", func() {
292291 Table: 100,
293292 Routing: Routing{
294293 RoutingPolicy: []RoutingPolicySpec{{
295- Priority: ptr.To(uint32 (32766)),
294+ Priority: ptr.To(int64 (32766)),
296295 }},
297296 },
298297 }},
@@ -342,7 +341,6 @@ var _ = Describe("ProxmoxMachine Test", func() {
342341 }
343342 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("should be greater than or equal to 100" )))
344343 })
345- /* rejected by validation
346344 It ("Should only allow spec.vmIDRange.end >= spec.vmIDRange.start" , func () {
347345 dm := defaultMachine ()
348346 dm .Spec .VMIDRange = & VMIDRange {
@@ -356,15 +354,15 @@ var _ = Describe("ProxmoxMachine Test", func() {
356354 dm .Spec .VMIDRange = & VMIDRange {
357355 Start : 100 ,
358356 }
359- Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.end in body should be greater than or equal to 100 ")))
357+ Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("spec.vmIDRange.end: Required value " )))
360358 })
361359 It ("Should only allow spec.vmIDRange.end if spec.vmIDRange.start is set" , func () {
362360 dm := defaultMachine ()
363361 dm .Spec .VMIDRange = & VMIDRange {
364362 End : 100 ,
365363 }
366- Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("spec.vmIDRange.start in body should be greater than or equal to 100 ")))
367- })*/
364+ Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("spec.vmIDRange.start: Required value " )))
365+ })
368366 })
369367
370368 Context ("Tags" , func () {
@@ -386,12 +384,12 @@ var _ = Describe("ProxmoxMachine Test", func() {
386384 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("Invalid value" )))
387385 })
388386
389- /* It("Should not allow duplicated tags", func() {
387+ It ("Should not allow duplicated tags" , func () {
390388 dm := defaultMachine ()
391389 dm .Spec .Tags = []string {"foo" , "bar" , "foo" }
392390 Expect (k8sClient .Create (context .Background (), dm )).Should (MatchError (ContainSubstring ("Duplicate value" )))
393391 dm .Spec .Tags = []string {"foo" , "bar" }
394392 Expect (k8sClient .Create (context .Background (), dm )).To (Succeed ())
395- })*/
393+ })
396394 })
397395})
0 commit comments