@@ -176,6 +176,60 @@ func TestThresholdAdjustedReadyCondition(t *testing.T) {
176
176
Status : metav1 .ConditionTrue ,
177
177
},
178
178
},
179
+ {
180
+ name : "ready condition changes from true to false" ,
181
+ clusterData : & clusterData {
182
+ readyCondition : metav1 .ConditionTrue ,
183
+ thresholdStartTime : time .Now ().Add (- 10 * time .Minute ),
184
+ },
185
+ currentCondition : & metav1.Condition {
186
+ Type : clusterv1alpha1 .ClusterConditionReady ,
187
+ Status : metav1 .ConditionTrue ,
188
+ },
189
+ observedCondition : & metav1.Condition {
190
+ Type : clusterv1alpha1 .ClusterConditionReady ,
191
+ Status : metav1 .ConditionFalse ,
192
+ },
193
+ expectedCondition : & metav1.Condition {
194
+ Type : clusterv1alpha1 .ClusterConditionReady ,
195
+ Status : metav1 .ConditionTrue ,
196
+ },
197
+ },
198
+ {
199
+ name : "ready condition changes from false to true" ,
200
+ clusterData : & clusterData {
201
+ readyCondition : metav1 .ConditionFalse ,
202
+ thresholdStartTime : time .Now ().Add (- 10 * time .Minute ),
203
+ },
204
+ currentCondition : & metav1.Condition {
205
+ Type : clusterv1alpha1 .ClusterConditionReady ,
206
+ Status : metav1 .ConditionFalse ,
207
+ },
208
+ observedCondition : & metav1.Condition {
209
+ Type : clusterv1alpha1 .ClusterConditionReady ,
210
+ Status : metav1 .ConditionTrue ,
211
+ },
212
+ expectedCondition : & metav1.Condition {
213
+ Type : clusterv1alpha1 .ClusterConditionReady ,
214
+ Status : metav1 .ConditionFalse ,
215
+ },
216
+ },
217
+ {
218
+ name : "current condition is nil, should return observed condition" ,
219
+ clusterData : & clusterData {
220
+ readyCondition : metav1 .ConditionFalse ,
221
+ thresholdStartTime : time .Now ().Add (- clusterFailureThreshold ),
222
+ },
223
+ currentCondition : nil ,
224
+ observedCondition : & metav1.Condition {
225
+ Type : clusterv1alpha1 .ClusterConditionReady ,
226
+ Status : metav1 .ConditionTrue ,
227
+ },
228
+ expectedCondition : & metav1.Condition {
229
+ Type : clusterv1alpha1 .ClusterConditionReady ,
230
+ Status : metav1 .ConditionTrue ,
231
+ },
232
+ },
179
233
}
180
234
181
235
for _ , tt := range tests {
0 commit comments