@@ -91,17 +91,23 @@ func testPodIRSA(annotations map[string]string) *corev1.Pod {
91
91
func TestShouldInject (t * testing.T ) {
92
92
tests := []struct {
93
93
annotations map [string ]string
94
+ phase corev1.PodPhase
94
95
inject bool
95
96
}{
96
- {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "" }, true },
97
- {map [string ]string {AnnotationAgentInject : "false" , AnnotationAgentStatus : "" }, false },
98
- {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "injected" }, false },
99
- {map [string ]string {AnnotationAgentInject : "false" , AnnotationAgentStatus : "injected" }, false },
100
- {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "update" }, true },
97
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "" }, corev1 .PodPending , true },
98
+ {map [string ]string {AnnotationAgentInject : "false" , AnnotationAgentStatus : "" }, corev1 .PodPending , false },
99
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "injected" }, corev1 .PodPending , false },
100
+ {map [string ]string {AnnotationAgentInject : "false" , AnnotationAgentStatus : "injected" }, corev1 .PodPending , false },
101
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "update" }, corev1 .PodPending , true },
102
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "" }, corev1 .PodRunning , false },
103
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "" }, corev1 .PodSucceeded , false },
104
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "" }, corev1 .PodFailed , false },
105
+ {map [string ]string {AnnotationAgentInject : "true" , AnnotationAgentStatus : "update" }, corev1 .PodRunning , false },
101
106
}
102
107
103
108
for _ , tt := range tests {
104
109
pod := testPod (tt .annotations )
110
+ pod .Status .Phase = tt .phase
105
111
inject , err := ShouldInject (pod )
106
112
if err != nil {
107
113
t .Errorf ("got error, shouldn't have: %s" , err )
0 commit comments