@@ -670,3 +670,82 @@ func TestMergeHostAliases(t *testing.T) {
670
670
assert .Equal (t , "1.2.3.5" , merged [1 ].IP )
671
671
assert .Equal (t , []string {"abc" }, merged [1 ].Hostnames )
672
672
}
673
+
674
+ func TestTolerations (t * testing.T ) {
675
+ type args struct {
676
+ defaultTolerations []corev1.Toleration
677
+ overrideTolerations []corev1.Toleration
678
+ }
679
+ tests := []struct {
680
+ name string
681
+ args args
682
+ want []corev1.Toleration
683
+ }{
684
+ {
685
+ name : "override tolerations is nil" ,
686
+ args : args {
687
+ defaultTolerations : []corev1.Toleration {
688
+ {
689
+ Key : "key1" ,
690
+ Value : "value1" ,
691
+ Operator : corev1 .TolerationOpEqual ,
692
+ },
693
+ {
694
+ Key : "key1" ,
695
+ Value : "value2" ,
696
+ Operator : corev1 .TolerationOpExists ,
697
+ },
698
+ },
699
+ overrideTolerations : nil ,
700
+ },
701
+ want : []corev1.Toleration {
702
+ {
703
+ Key : "key1" ,
704
+ Value : "value1" ,
705
+ Operator : corev1 .TolerationOpEqual ,
706
+ },
707
+ {
708
+ Key : "key1" ,
709
+ Value : "value2" ,
710
+ Operator : corev1 .TolerationOpExists ,
711
+ },
712
+ },
713
+ },
714
+
715
+ {
716
+ name : "default tolerations is nil" ,
717
+ args : args {
718
+ defaultTolerations : nil ,
719
+ overrideTolerations : []corev1.Toleration {
720
+ {
721
+ Key : "key1" ,
722
+ Value : "value1" ,
723
+ Operator : corev1 .TolerationOpEqual ,
724
+ },
725
+ {
726
+ Key : "key1" ,
727
+ Value : "value2" ,
728
+ Operator : corev1 .TolerationOpExists ,
729
+ },
730
+ },
731
+ },
732
+ want : []corev1.Toleration {
733
+ {
734
+ Key : "key1" ,
735
+ Value : "value1" ,
736
+ Operator : corev1 .TolerationOpEqual ,
737
+ },
738
+ {
739
+ Key : "key1" ,
740
+ Value : "value2" ,
741
+ Operator : corev1 .TolerationOpExists ,
742
+ },
743
+ },
744
+ },
745
+ }
746
+ for _ , tt := range tests {
747
+ t .Run (tt .name , func (t * testing.T ) {
748
+ assert .Equalf (t , tt .want , Tolerations (tt .args .defaultTolerations , tt .args .overrideTolerations ), "Tolerations(%v, %v)" , tt .args .defaultTolerations , tt .args .overrideTolerations )
749
+ })
750
+ }
751
+ }
0 commit comments