@@ -261,7 +261,6 @@ func TestNodesMatchExpectedCount(t *testing.T) {
261
261
}
262
262
263
263
func TestGetInfraMachinePool (t * testing.T ) {
264
- // Create a test namespace
265
264
testNamespace := & corev1.Namespace {
266
265
ObjectMeta : metav1.ObjectMeta {
267
266
Name : "test-namespace" ,
@@ -271,14 +270,13 @@ func TestGetInfraMachinePool(t *testing.T) {
271
270
},
272
271
}
273
272
274
- // Create a test machine pool with name exactly matching "infra"
275
273
testMachinePool := & hivev1.MachinePool {
276
274
ObjectMeta : metav1.ObjectMeta {
277
- Name : "test-cluster-infra" , // Name in metadata
275
+ Name : "test-cluster-infra" ,
278
276
Namespace : "test-namespace" ,
279
277
},
280
278
Spec : hivev1.MachinePoolSpec {
281
- Name : "infra" , // This is what the code checks for
279
+ Name : "infra" ,
282
280
Platform : hivev1.MachinePoolPlatform {
283
281
AWS : & hivev1aws.MachinePoolPlatform {
284
282
InstanceType : "r5.xlarge" ,
@@ -287,10 +285,7 @@ func TestGetInfraMachinePool(t *testing.T) {
287
285
},
288
286
}
289
287
290
- // Create mock client
291
288
mockHive := & MockClient {}
292
-
293
- // Set up mock expectations for namespace list - first call
294
289
firstCall := mockHive .On ("List" , mock .Anything , mock .MatchedBy (func (obj interface {}) bool {
295
290
_ , ok := obj .(* corev1.NamespaceList )
296
291
return ok
@@ -300,7 +295,6 @@ func TestGetInfraMachinePool(t *testing.T) {
300
295
nsList .Items = []corev1.Namespace {* testNamespace }
301
296
})
302
297
303
- // Set up mock expectations for machine pool list - second call
304
298
secondCall := mockHive .On ("List" , mock .Anything , mock .MatchedBy (func (obj interface {}) bool {
305
299
_ , ok := obj .(* hivev1.MachinePoolList )
306
300
return ok
@@ -310,22 +304,17 @@ func TestGetInfraMachinePool(t *testing.T) {
310
304
mpList .Items = []hivev1.MachinePool {* testMachinePool }
311
305
})
312
306
313
- // Create Infra instance
314
307
infra := & Infra {
315
308
clusterId : "test-cluster" ,
316
309
hive : mockHive ,
317
310
}
318
311
319
- // Call the function
320
312
mp , err := infra .getInfraMachinePool (context .Background ())
321
313
322
- // Verify results
323
314
assert .NoError (t , err )
324
315
assert .NotNil (t , mp )
325
316
assert .Equal (t , "infra" , mp .Spec .Name )
326
317
assert .Equal (t , "r5.xlarge" , mp .Spec .Platform .AWS .InstanceType )
327
-
328
- // Verify mock was called correctly
329
318
mockHive .AssertExpectations (t )
330
319
}
331
320
@@ -428,5 +417,3 @@ func TestGetInfraMachinePoolNoInfraPool(t *testing.T) {
428
417
// Verify mock was called correctly
429
418
mockHive .AssertExpectations (t )
430
419
}
431
-
432
-
0 commit comments