@@ -755,9 +755,9 @@ func TestListControllerPods(t *testing.T) {
755
755
useElectionIDSelector : true ,
756
756
electionID : "test-election-id" ,
757
757
podLabels : map [string ]string {
758
- "app" : "ingress-nginx" ,
759
- "pod-template-hash" : "abc123" ,
760
- ElectionIDLabelKey : "test-election-id" ,
758
+ "app" : "ingress-nginx" ,
759
+ "pod-template-hash" : "abc123" ,
760
+ ElectionIDLabelKey : "test-election-id" ,
761
761
},
762
762
expectedLabelSelectorContains : ElectionIDLabelKey ,
763
763
},
@@ -766,7 +766,7 @@ func TestListControllerPods(t *testing.T) {
766
766
useElectionIDSelector : false ,
767
767
electionID : "test-election-id" ,
768
768
podLabels : map [string ]string {
769
- "app" : "ingress-nginx" ,
769
+ "app" : "ingress-nginx" ,
770
770
"pod-template-hash" : "abc123" ,
771
771
},
772
772
expectedLabelSelectorContains : "app=ingress-nginx" ,
@@ -802,9 +802,9 @@ func TestListControllerPods(t *testing.T) {
802
802
// Create a status sync with our test configuration
803
803
st := & statusSync {
804
804
Config : Config {
805
- Client : client ,
805
+ Client : client ,
806
806
UseElectionIDSelectorOnShutdown : tc .useElectionIDSelector ,
807
- ElectionID : tc .electionID ,
807
+ ElectionID : tc .electionID ,
808
808
},
809
809
}
810
810
@@ -824,11 +824,8 @@ func TestListControllerPods(t *testing.T) {
824
824
if len (podList .Items ) != 0 && tc .podLabels [ElectionIDLabelKey ] != tc .electionID {
825
825
t .Errorf ("expected 0 pods but got %d" , len (podList .Items ))
826
826
}
827
- } else {
828
- // Should have exactly one pod
829
- if len (podList .Items ) != 1 {
830
- t .Errorf ("expected 1 pod but got %d" , len (podList .Items ))
831
- }
827
+ } else if len (podList .Items ) != 1 {
828
+ t .Errorf ("expected 1 pod but got %d" , len (podList .Items ))
832
829
}
833
830
})
834
831
}
@@ -837,26 +834,26 @@ func TestListControllerPods(t *testing.T) {
837
834
// TestIsRunningMultiplePods tests the isRunningMultiplePods function with different label selectors
838
835
func TestIsRunningMultiplePods (t * testing.T ) {
839
836
testCases := []struct {
840
- name string
841
- useElectionID bool
842
- electionID string
843
- podLabels []map [string ]string
844
- expectedMultiple bool
837
+ name string
838
+ useElectionID bool
839
+ electionID string
840
+ podLabels []map [string ]string
841
+ expectedMultiple bool
845
842
}{
846
843
{
847
844
name : "multiple pods with same electionID" ,
848
845
useElectionID : true ,
849
846
electionID : "test-election-id" ,
850
847
podLabels : []map [string ]string {
851
848
{
852
- "app" : "ingress-nginx" ,
849
+ "app" : "ingress-nginx" ,
853
850
"pod-template-hash" : "abc123" ,
854
- ElectionIDLabelKey : "test-election-id" ,
851
+ ElectionIDLabelKey : "test-election-id" ,
855
852
},
856
853
{
857
- "app" : "ingress-nginx" ,
854
+ "app" : "ingress-nginx" ,
858
855
"pod-template-hash" : "def456" ,
859
- ElectionIDLabelKey : "test-election-id" ,
856
+ ElectionIDLabelKey : "test-election-id" ,
860
857
},
861
858
},
862
859
expectedMultiple : true ,
@@ -867,14 +864,14 @@ func TestIsRunningMultiplePods(t *testing.T) {
867
864
electionID : "test-election-id" ,
868
865
podLabels : []map [string ]string {
869
866
{
870
- "app" : "ingress-nginx" ,
867
+ "app" : "ingress-nginx" ,
871
868
"pod-template-hash" : "abc123" ,
872
- ElectionIDLabelKey : "test-election-id" ,
869
+ ElectionIDLabelKey : "test-election-id" ,
873
870
},
874
871
{
875
- "app" : "ingress-nginx" ,
872
+ "app" : "ingress-nginx" ,
876
873
"pod-template-hash" : "def456" ,
877
- ElectionIDLabelKey : "other-election-id" ,
874
+ ElectionIDLabelKey : "other-election-id" ,
878
875
},
879
876
},
880
877
expectedMultiple : false ,
@@ -885,9 +882,9 @@ func TestIsRunningMultiplePods(t *testing.T) {
885
882
electionID : "test-election-id" ,
886
883
podLabels : []map [string ]string {
887
884
{
888
- "app" : "ingress-nginx" ,
885
+ "app" : "ingress-nginx" ,
889
886
"pod-template-hash" : "abc123" ,
890
- ElectionIDLabelKey : "test-election-id" ,
887
+ ElectionIDLabelKey : "test-election-id" ,
891
888
},
892
889
},
893
890
expectedMultiple : false ,
@@ -898,11 +895,11 @@ func TestIsRunningMultiplePods(t *testing.T) {
898
895
electionID : "test-election-id" ,
899
896
podLabels : []map [string ]string {
900
897
{
901
- "app" : "ingress-nginx" ,
898
+ "app" : "ingress-nginx" ,
902
899
"pod-template-hash" : "abc123" ,
903
900
},
904
901
{
905
- "app" : "ingress-nginx" ,
902
+ "app" : "ingress-nginx" ,
906
903
"pod-template-hash" : "def456" ,
907
904
},
908
905
},
@@ -943,9 +940,9 @@ func TestIsRunningMultiplePods(t *testing.T) {
943
940
// Create a status sync with our test configuration
944
941
st := & statusSync {
945
942
Config : Config {
946
- Client : client ,
943
+ Client : client ,
947
944
UseElectionIDSelectorOnShutdown : tc .useElectionID ,
948
- ElectionID : tc .electionID ,
945
+ ElectionID : tc .electionID ,
949
946
},
950
947
}
951
948
0 commit comments