@@ -561,7 +561,7 @@ func TestEvaluateExpression(t *testing.T) {
561
561
expectError : false ,
562
562
},
563
563
{
564
- name : "GreaterThan comparison with strings" ,
564
+ name : "GreaterThan comparison with strings - true " ,
565
565
expr : & util.LogicalExpression {
566
566
GreaterThan : & util.ValueComparison {
567
567
Left : & util.ValueSource {Literal : "xyz" },
@@ -594,7 +594,7 @@ func TestEvaluateExpression(t *testing.T) {
594
594
expectError : false ,
595
595
},
596
596
{
597
- name : "LessThan comparison with strings" ,
597
+ name : "LessThan comparison with strings - true " ,
598
598
expr : & util.LogicalExpression {
599
599
LessThan : & util.ValueComparison {
600
600
Left : & util.ValueSource {Literal : "abc" },
@@ -604,6 +604,128 @@ func TestEvaluateExpression(t *testing.T) {
604
604
expectedResult : true ,
605
605
expectError : false ,
606
606
},
607
+ // Kubernetes resource quantity tests
608
+ {
609
+ name : "GreaterThan comparison with memory quantities - true" ,
610
+ expr : & util.LogicalExpression {
611
+ GreaterThan : & util.ValueComparison {
612
+ Left : & util.ValueSource {Literal : "10Gi" },
613
+ Right : & util.ValueSource {Literal : "2Gi" },
614
+ },
615
+ },
616
+ expectedResult : true ,
617
+ expectError : false ,
618
+ },
619
+ {
620
+ name : "GreaterThan comparison with memory quantities - false" ,
621
+ expr : & util.LogicalExpression {
622
+ GreaterThan : & util.ValueComparison {
623
+ Left : & util.ValueSource {Literal : "100Mi" },
624
+ Right : & util.ValueSource {Literal : "1Gi" },
625
+ },
626
+ },
627
+ expectedResult : false ,
628
+ expectError : false ,
629
+ },
630
+ {
631
+ name : "LessThan comparison with memory quantities - true" ,
632
+ expr : & util.LogicalExpression {
633
+ LessThan : & util.ValueComparison {
634
+ Left : & util.ValueSource {Literal : "500Mi" },
635
+ Right : & util.ValueSource {Literal : "1Gi" },
636
+ },
637
+ },
638
+ expectedResult : true ,
639
+ expectError : false ,
640
+ },
641
+ {
642
+ name : "LessThan comparison with memory quantities - false" ,
643
+ expr : & util.LogicalExpression {
644
+ LessThan : & util.ValueComparison {
645
+ Left : & util.ValueSource {Literal : "5Gi" },
646
+ Right : & util.ValueSource {Literal : "2Gi" },
647
+ },
648
+ },
649
+ expectedResult : false ,
650
+ expectError : false ,
651
+ },
652
+ {
653
+ name : "Equal comparison with CPU quantities" ,
654
+ expr : & util.LogicalExpression {
655
+ Equal : & util.ValueComparison {
656
+ Left : & util.ValueSource {Literal : "1000m" },
657
+ Right : & util.ValueSource {Literal : "1" },
658
+ },
659
+ },
660
+ expectedResult : true ,
661
+ expectError : false ,
662
+ },
663
+ {
664
+ name : "Equal comparison with different unit formats" ,
665
+ expr : & util.LogicalExpression {
666
+ Equal : & util.ValueComparison {
667
+ Left : & util.ValueSource {Literal : "1Gi" },
668
+ Right : & util.ValueSource {Literal : "1024Mi" },
669
+ },
670
+ },
671
+ expectedResult : true ,
672
+ expectError : false ,
673
+ },
674
+ {
675
+ name : "GreaterThan comparison with CPU quantities" ,
676
+ expr : & util.LogicalExpression {
677
+ GreaterThan : & util.ValueComparison {
678
+ Left : & util.ValueSource {Literal : "2" },
679
+ Right : & util.ValueSource {Literal : "1500m" },
680
+ },
681
+ },
682
+ expectedResult : true ,
683
+ expectError : false ,
684
+ },
685
+ {
686
+ name : "GreaterThan comparison with mixed format units" ,
687
+ expr : & util.LogicalExpression {
688
+ GreaterThan : & util.ValueComparison {
689
+ Left : & util.ValueSource {Literal : "1Mi" },
690
+ Right : & util.ValueSource {Literal : "1024Ki" },
691
+ },
692
+ },
693
+ expectedResult : false ,
694
+ expectError : false ,
695
+ },
696
+ {
697
+ name : "Mixed resource types - comparing memory and CPU" ,
698
+ expr : & util.LogicalExpression {
699
+ Equal : & util.ValueComparison {
700
+ Left : & util.ValueSource {Literal : "100m" },
701
+ Right : & util.ValueSource {Literal : "100Mi" },
702
+ },
703
+ },
704
+ expectedResult : false ,
705
+ expectError : false ,
706
+ },
707
+ {
708
+ name : "NotEqual comparison with memory quantities - true" ,
709
+ expr : & util.LogicalExpression {
710
+ NotEqual : & util.ValueComparison {
711
+ Left : & util.ValueSource {Literal : "2Gi" },
712
+ Right : & util.ValueSource {Literal : "1Gi" },
713
+ },
714
+ },
715
+ expectedResult : true ,
716
+ expectError : false ,
717
+ },
718
+ {
719
+ name : "NotEqual comparison with memory quantities - false" ,
720
+ expr : & util.LogicalExpression {
721
+ NotEqual : & util.ValueComparison {
722
+ Left : & util.ValueSource {Literal : "1Gi" },
723
+ Right : & util.ValueSource {Literal : "1024Mi" },
724
+ },
725
+ },
726
+ expectedResult : false ,
727
+ expectError : false ,
728
+ },
607
729
{
608
730
name : "And operator - all true" ,
609
731
expr : & util.LogicalExpression {
0 commit comments