@@ -101,6 +101,8 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
101
101
Controller : & ownerutil .NotController ,
102
102
BlockOwnerDeletion : & ownerutil .DontBlockOwnerDeletion ,
103
103
}}
104
+ expectedRevisionHistoryLimit = int32 (1 )
105
+ defaultRevisionHistoryLimit = int32 (10 )
104
106
)
105
107
106
108
type inputs struct {
@@ -126,11 +128,15 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
126
128
strategyDeploymentSpecs : []v1alpha1.StrategyDeploymentSpec {
127
129
{
128
130
Name : "test-deployment-1" ,
129
- Spec : appsv1.DeploymentSpec {},
131
+ Spec : appsv1.DeploymentSpec {
132
+ RevisionHistoryLimit : & defaultRevisionHistoryLimit ,
133
+ },
130
134
},
131
135
{
132
136
Name : "test-deployment-2" ,
133
- Spec : appsv1.DeploymentSpec {},
137
+ Spec : appsv1.DeploymentSpec {
138
+ RevisionHistoryLimit : nil ,
139
+ },
134
140
},
135
141
{
136
142
Name : "test-deployment-3" ,
@@ -168,6 +174,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
168
174
},
169
175
},
170
176
Spec : appsv1.DeploymentSpec {
177
+ RevisionHistoryLimit : & expectedRevisionHistoryLimit ,
171
178
Template : corev1.PodTemplateSpec {
172
179
ObjectMeta : metav1.ObjectMeta {
173
180
Annotations : map [string ]string {},
@@ -189,6 +196,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
189
196
},
190
197
},
191
198
Spec : appsv1.DeploymentSpec {
199
+ RevisionHistoryLimit : & expectedRevisionHistoryLimit ,
192
200
Template : corev1.PodTemplateSpec {
193
201
ObjectMeta : metav1.ObjectMeta {
194
202
Annotations : map [string ]string {},
@@ -210,6 +218,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
210
218
},
211
219
},
212
220
Spec : appsv1.DeploymentSpec {
221
+ RevisionHistoryLimit : & expectedRevisionHistoryLimit ,
213
222
Template : corev1.PodTemplateSpec {
214
223
ObjectMeta : metav1.ObjectMeta {
215
224
Annotations : map [string ]string {},
@@ -234,6 +243,7 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
234
243
dep := fakeClient .CreateOrUpdateDeploymentArgsForCall (i )
235
244
expectedDeployment .Spec .Template .Annotations = map [string ]string {}
236
245
require .Equal (t , expectedDeployment .OwnerReferences , dep .OwnerReferences )
246
+ require .Equal (t , expectedDeployment .Spec .RevisionHistoryLimit , dep .Spec .RevisionHistoryLimit )
237
247
}(i , m .expectedDeployment )
238
248
}
239
249
@@ -299,6 +309,7 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
299
309
},
300
310
}
301
311
312
+ revisionHistoryLimit := int32 (1 )
302
313
for _ , tt := range tests {
303
314
t .Run (tt .description , func (t * testing.T ) {
304
315
fakeClient := new (clientfakes.FakeInstallStrategyDeploymentInterface )
@@ -307,6 +318,7 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
307
318
308
319
dep := testDeployment ("olm-dep-1" , namespace , & mockOwner )
309
320
dep .Spec .Template .SetAnnotations (map [string ]string {"test" : "annotation" })
321
+ dep .Spec .RevisionHistoryLimit = & revisionHistoryLimit
310
322
dep .SetLabels (labels .CloneAndAddLabel (dep .ObjectMeta .GetLabels (), DeploymentSpecHashLabelKey , HashDeploymentSpec (dep .Spec )))
311
323
fakeClient .FindAnyDeploymentsMatchingLabelsReturns (
312
324
[]* appsv1.Deployment {
@@ -323,6 +335,7 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
323
335
324
336
deployment := testDeployment ("olm-dep-1" , namespace , & mockOwner )
325
337
deployment .Spec .Template .SetAnnotations (map [string ]string {"test" : "annotation" })
338
+ deployment .Spec .RevisionHistoryLimit = & revisionHistoryLimit
326
339
deployment .SetLabels (labels .CloneAndAddLabel (dep .ObjectMeta .GetLabels (), DeploymentSpecHashLabelKey , HashDeploymentSpec (deployment .Spec )))
327
340
fakeClient .CreateOrUpdateDeploymentReturns (& deployment , tt .createDeploymentErr )
328
341
defer func () {
@@ -332,7 +345,6 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
332
345
if tt .createDeploymentErr != nil {
333
346
err := installer .Install (strategy )
334
347
require .Error (t , err )
335
- return
336
348
}
337
349
})
338
350
}
0 commit comments