@@ -272,15 +272,15 @@ func TestCheckFallbackValid(t *testing.T) {
272
272
for _ , test := range tests {
273
273
t .Run (test .name , func (t * testing.T ) {
274
274
err := CheckFallbackValid (test .scaledObject )
275
-
275
+
276
276
if test .expectedError && err == nil {
277
277
t .Error ("Expected error but got nil" )
278
278
}
279
-
279
+
280
280
if ! test .expectedError && err != nil {
281
281
t .Errorf ("Expected no error but got: %v" , err )
282
282
}
283
-
283
+
284
284
if test .expectedError && err != nil && test .errorContains != "" {
285
285
if ! contains (err .Error (), test .errorContains ) {
286
286
t .Errorf ("Error message does not contain expected text.\n Expected to contain: %s\n Actual: %s" ,
@@ -381,52 +381,52 @@ func TestNeedToBePausedByAnnotation(t *testing.T) {
381
381
pausedReplicaCount := int32 (5 )
382
382
383
383
tests := []struct {
384
- name string
385
- annotations map [string ]string
384
+ name string
385
+ annotations map [string ]string
386
386
pausedReplicaCount * int32
387
- expectResult bool
387
+ expectResult bool
388
388
}{
389
389
{
390
- name : "No annotations" ,
391
- annotations : nil ,
390
+ name : "No annotations" ,
391
+ annotations : nil ,
392
392
pausedReplicaCount : nil ,
393
- expectResult : false ,
393
+ expectResult : false ,
394
394
},
395
395
{
396
- name : "PausedAnnotation with true value" ,
397
- annotations : map [string ]string {PausedAnnotation : "true" },
396
+ name : "PausedAnnotation with true value" ,
397
+ annotations : map [string ]string {PausedAnnotation : "true" },
398
398
pausedReplicaCount : nil ,
399
- expectResult : true ,
399
+ expectResult : true ,
400
400
},
401
401
{
402
- name : "PausedAnnotation with false value" ,
403
- annotations : map [string ]string {PausedAnnotation : "false" },
402
+ name : "PausedAnnotation with false value" ,
403
+ annotations : map [string ]string {PausedAnnotation : "false" },
404
404
pausedReplicaCount : nil ,
405
- expectResult : false ,
405
+ expectResult : false ,
406
406
},
407
407
{
408
- name : "PausedAnnotation with invalid value" ,
409
- annotations : map [string ]string {PausedAnnotation : "invalid" },
408
+ name : "PausedAnnotation with invalid value" ,
409
+ annotations : map [string ]string {PausedAnnotation : "invalid" },
410
410
pausedReplicaCount : nil ,
411
- expectResult : true , // Non-boolean values should default to true
411
+ expectResult : true , // Non-boolean values should default to true
412
412
},
413
413
{
414
- name : "PausedReplicasAnnotation with value and status set" ,
415
- annotations : map [string ]string {PausedReplicasAnnotation : "5" },
414
+ name : "PausedReplicasAnnotation with value and status set" ,
415
+ annotations : map [string ]string {PausedReplicasAnnotation : "5" },
416
416
pausedReplicaCount : & pausedReplicaCount ,
417
- expectResult : true ,
417
+ expectResult : true ,
418
418
},
419
419
{
420
- name : "PausedReplicasAnnotation with value but no status set" ,
421
- annotations : map [string ]string {PausedReplicasAnnotation : "5" },
420
+ name : "PausedReplicasAnnotation with value but no status set" ,
421
+ annotations : map [string ]string {PausedReplicasAnnotation : "5" },
422
422
pausedReplicaCount : nil ,
423
- expectResult : false ,
423
+ expectResult : false ,
424
424
},
425
425
{
426
- name : "Both annotations set" ,
427
- annotations : map [string ]string {PausedAnnotation : "true" , PausedReplicasAnnotation : "5" },
426
+ name : "Both annotations set" ,
427
+ annotations : map [string ]string {PausedAnnotation : "true" , PausedReplicasAnnotation : "5" },
428
428
pausedReplicaCount : & pausedReplicaCount ,
429
- expectResult : true , // PausedReplicasAnnotation has precedence
429
+ expectResult : true , // PausedReplicasAnnotation has precedence
430
430
},
431
431
}
432
432
@@ -519,7 +519,7 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
519
519
idle0 := int32 (0 )
520
520
idle1 := int32 (1 )
521
521
idle2 := int32 (2 )
522
-
522
+
523
523
tests := []struct {
524
524
name string
525
525
scaledObject * ScaledObject
@@ -530,8 +530,8 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
530
530
name : "Valid: min 1, max 5, no idle" ,
531
531
scaledObject : & ScaledObject {
532
532
Spec : ScaledObjectSpec {
533
- MinReplicaCount : & min1 ,
534
- MaxReplicaCount : & max5 ,
533
+ MinReplicaCount : & min1 ,
534
+ MaxReplicaCount : & max5 ,
535
535
IdleReplicaCount : nil ,
536
536
},
537
537
},
@@ -541,8 +541,8 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
541
541
name : "Valid: min 1, max 5, idle 0" ,
542
542
scaledObject : & ScaledObject {
543
543
Spec : ScaledObjectSpec {
544
- MinReplicaCount : & min1 ,
545
- MaxReplicaCount : & max5 ,
544
+ MinReplicaCount : & min1 ,
545
+ MaxReplicaCount : & max5 ,
546
546
IdleReplicaCount : & idle0 ,
547
547
},
548
548
},
@@ -563,8 +563,8 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
563
563
name : "Invalid: idle 1 == min 1" ,
564
564
scaledObject : & ScaledObject {
565
565
Spec : ScaledObjectSpec {
566
- MinReplicaCount : & min1 ,
567
- MaxReplicaCount : & max5 ,
566
+ MinReplicaCount : & min1 ,
567
+ MaxReplicaCount : & max5 ,
568
568
IdleReplicaCount : & idle1 ,
569
569
},
570
570
},
@@ -575,8 +575,8 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
575
575
name : "Invalid: idle 2 > min 1" ,
576
576
scaledObject : & ScaledObject {
577
577
Spec : ScaledObjectSpec {
578
- MinReplicaCount : & min1 ,
579
- MaxReplicaCount : & max5 ,
578
+ MinReplicaCount : & min1 ,
579
+ MaxReplicaCount : & max5 ,
580
580
IdleReplicaCount : & idle2 ,
581
581
},
582
582
},
@@ -588,18 +588,18 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
588
588
for _ , test := range tests {
589
589
t .Run (test .name , func (t * testing.T ) {
590
590
err := CheckReplicaCountBoundsAreValid (test .scaledObject )
591
-
591
+
592
592
if test .expectedError && err == nil {
593
593
t .Error ("Expected error but got nil" )
594
594
}
595
-
595
+
596
596
if ! test .expectedError && err != nil {
597
597
t .Errorf ("Expected no error but got: %v" , err )
598
598
}
599
-
599
+
600
600
if test .expectedError && err != nil && test .errorContains != "" {
601
601
if ! strings .Contains (err .Error (), test .errorContains ) {
602
- t .Errorf ("Error message does not contain expected text.\n Expected to contain: %s\n Actual: %s" ,
602
+ t .Errorf ("Error message does not contain expected text.\n Expected to contain: %s\n Actual: %s" ,
603
603
test .errorContains , err .Error ())
604
604
}
605
605
}
@@ -608,8 +608,8 @@ func TestCheckReplicaCountBoundsAreValid(t *testing.T) {
608
608
}
609
609
610
610
func TestGetHPAReplicas (t * testing.T ) {
611
- min0 := int32 (0 )
612
- min5 := int32 (5 )
611
+ min0 := int32 (0 )
612
+ min5 := int32 (5 )
613
613
max10 := int32 (10 )
614
614
615
615
tests := []struct {
@@ -623,8 +623,8 @@ func TestGetHPAReplicas(t *testing.T) {
623
623
name : "Default min and max" ,
624
624
minReplicaCount : nil ,
625
625
maxReplicaCount : nil ,
626
- expectedMin : 1 , // default minimum
627
- expectedMax : 100 , // default maximum
626
+ expectedMin : 1 , // default minimum
627
+ expectedMax : 100 , // default maximum
628
628
},
629
629
{
630
630
name : "Custom min, default max" ,
@@ -651,7 +651,7 @@ func TestGetHPAReplicas(t *testing.T) {
651
651
name : "Zero min, default max" ,
652
652
minReplicaCount : & min0 ,
653
653
maxReplicaCount : nil ,
654
- expectedMin : 1 , // should use default for 0 value
654
+ expectedMin : 1 , // should use default for 0 value
655
655
expectedMax : 100 ,
656
656
},
657
657
}
0 commit comments