@@ -1015,15 +1015,16 @@ func TestAtomicRelease_Reconcile_Scenarios(t *testing.T) {
1015
1015
1016
1016
func TestAtomicRelease_actionForState (t * testing.T ) {
1017
1017
tests := []struct {
1018
- name string
1019
- releases []* helmrelease.Release
1020
- annotations map [string ]string
1021
- spec func (spec * v2.HelmReleaseSpec )
1022
- status func (releases []* helmrelease.Release ) v2.HelmReleaseStatus
1023
- state ReleaseState
1024
- want ActionReconciler
1025
- wantEvent * corev1.Event
1026
- wantErr error
1018
+ name string
1019
+ releases []* helmrelease.Release
1020
+ annotations map [string ]string
1021
+ spec func (spec * v2.HelmReleaseSpec )
1022
+ status func (releases []* helmrelease.Release ) v2.HelmReleaseStatus
1023
+ state ReleaseState
1024
+ want ActionReconciler
1025
+ wantEvent * corev1.Event
1026
+ wantErr error
1027
+ assertConditions []metav1.Condition
1027
1028
}{
1028
1029
{
1029
1030
name : "in-sync release does not trigger any action" ,
@@ -1053,6 +1054,25 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1053
1054
},
1054
1055
want : & Upgrade {},
1055
1056
},
1057
+ {
1058
+ name : "in-sync release with stale remediated condition" ,
1059
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1060
+ return v2.HelmReleaseStatus {
1061
+ History : v2.Snapshots {
1062
+ {Version : 1 },
1063
+ },
1064
+ Conditions : []metav1.Condition {
1065
+ * conditions .FalseCondition (v2 .ReleasedCondition , v2 .UpgradeFailedReason , "upgrade failed" ),
1066
+ * conditions .TrueCondition (v2 .RemediatedCondition , v2 .RollbackSucceededReason , "rolled back" ),
1067
+ },
1068
+ }
1069
+ },
1070
+ state : ReleaseState {Status : ReleaseStatusInSync },
1071
+ want : nil ,
1072
+ assertConditions : []metav1.Condition {
1073
+ * conditions .TrueCondition (v2 .ReleasedCondition , v2 .UpgradeSucceededReason , "upgrade succeeded" ),
1074
+ },
1075
+ },
1056
1076
{
1057
1077
name : "locked release triggers unlock action" ,
1058
1078
state : ReleaseState {Status : ReleaseStatusLocked },
@@ -1245,6 +1265,25 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1245
1265
state : ReleaseState {Status : ReleaseStatusUntested },
1246
1266
want : & Test {},
1247
1267
},
1268
+ {
1269
+ name : "untested release with stale remediated condition" ,
1270
+ status : func (releases []* helmrelease.Release ) v2.HelmReleaseStatus {
1271
+ return v2.HelmReleaseStatus {
1272
+ History : v2.Snapshots {
1273
+ {Version : 1 },
1274
+ },
1275
+ Conditions : []metav1.Condition {
1276
+ * conditions .FalseCondition (v2 .ReleasedCondition , v2 .UpgradeFailedReason , "upgrade failed" ),
1277
+ * conditions .TrueCondition (v2 .RemediatedCondition , v2 .RollbackSucceededReason , "rolled back" ),
1278
+ },
1279
+ }
1280
+ },
1281
+ state : ReleaseState {Status : ReleaseStatusUntested },
1282
+ want : & Test {},
1283
+ assertConditions : []metav1.Condition {
1284
+ * conditions .TrueCondition (v2 .ReleasedCondition , v2 .UpgradeSucceededReason , "upgrade succeeded" ),
1285
+ },
1286
+ },
1248
1287
{
1249
1288
name : "failed release without active remediation triggers upgrade" ,
1250
1289
state : ReleaseState {Status : ReleaseStatusFailed },
@@ -1513,6 +1552,8 @@ func TestAtomicRelease_actionForState(t *testing.T) {
1513
1552
} else {
1514
1553
g .Expect (recorder .GetEvents ()).To (BeEmpty ())
1515
1554
}
1555
+
1556
+ g .Expect (obj .Status .Conditions ).To (conditions .MatchConditions (tt .assertConditions ))
1516
1557
})
1517
1558
}
1518
1559
}
0 commit comments