@@ -2,7 +2,6 @@ package variablesources_test
2
2
3
3
import (
4
4
"encoding/json"
5
- "fmt"
6
5
"testing"
7
6
8
7
"github.com/operator-framework/deppy/pkg/deppy"
@@ -202,37 +201,36 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
202
201
},
203
202
}
204
203
205
- fakeBundleDeployments := func (bundleImages ... string ) []rukpakv1alpha1.BundleDeployment {
206
- bundleDeployments := []rukpakv1alpha1.BundleDeployment {}
207
- for idx , bundleImage := range bundleImages {
208
- bd := rukpakv1alpha1.BundleDeployment {
209
- ObjectMeta : metav1.ObjectMeta {
210
- Name : fmt .Sprintf ("bd-%d" , idx ),
211
- },
212
- Spec : rukpakv1alpha1.BundleDeploymentSpec {
213
- Template : & rukpakv1alpha1.BundleTemplate {
214
- Spec : rukpakv1alpha1.BundleSpec {
215
- Source : rukpakv1alpha1.BundleSource {
216
- Image : & rukpakv1alpha1.ImageSource {
217
- Ref : bundleImage ,
218
- },
204
+ fakeBundleDeployment := func (name , bundleImage string ) rukpakv1alpha1.BundleDeployment {
205
+ return rukpakv1alpha1.BundleDeployment {
206
+ ObjectMeta : metav1.ObjectMeta {
207
+ Name : name ,
208
+ },
209
+ Spec : rukpakv1alpha1.BundleDeploymentSpec {
210
+ Template : & rukpakv1alpha1.BundleTemplate {
211
+ Spec : rukpakv1alpha1.BundleSpec {
212
+ Source : rukpakv1alpha1.BundleSource {
213
+ Image : & rukpakv1alpha1.ImageSource {
214
+ Ref : bundleImage ,
219
215
},
220
216
},
221
217
},
222
218
},
223
- }
224
- bundleDeployments = append (bundleDeployments , bd )
219
+ },
225
220
}
226
-
227
- return bundleDeployments
228
221
}
229
222
230
223
t .Run ("with ForceSemverUpgradeConstraints feature gate enabled" , func (t * testing.T ) {
231
224
defer featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .ForceSemverUpgradeConstraints , true )()
232
225
233
226
t .Run ("with non-zero major version" , func (t * testing.T ) {
234
227
const bundleImage = "registry.io/repo/[email protected] "
235
- installedPackages , err := variablesources .MakeInstalledPackageVariables (allBundles , fakeBundleDeployments (bundleImage ))
228
+ installedPackages , err := variablesources .MakeInstalledPackageVariables (
229
+ allBundles ,
230
+ []rukpakv1alpha1.BundleDeployment {
231
+ fakeBundleDeployment ("test-bd" , bundleImage ),
232
+ },
233
+ )
236
234
require .NoError (t , err )
237
235
238
236
require .Len (t , installedPackages , 1 )
@@ -250,7 +248,12 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
250
248
t .Run ("with zero major version" , func (t * testing.T ) {
251
249
t .Run ("with zero minor version" , func (t * testing.T ) {
252
250
const bundleImage = "registry.io/repo/[email protected] "
253
- installedPackages , err := variablesources .MakeInstalledPackageVariables (allBundles , fakeBundleDeployments (bundleImage ))
251
+ installedPackages , err := variablesources .MakeInstalledPackageVariables (
252
+ allBundles ,
253
+ []rukpakv1alpha1.BundleDeployment {
254
+ fakeBundleDeployment ("test-bd" , bundleImage ),
255
+ },
256
+ )
254
257
require .NoError (t , err )
255
258
256
259
require .Len (t , installedPackages , 1 )
@@ -265,7 +268,12 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
265
268
266
269
t .Run ("with non-zero minor version" , func (t * testing.T ) {
267
270
const bundleImage = "registry.io/repo/[email protected] "
268
- installedPackages , err := variablesources .MakeInstalledPackageVariables (allBundles , fakeBundleDeployments (bundleImage ))
271
+ installedPackages , err := variablesources .MakeInstalledPackageVariables (
272
+ allBundles ,
273
+ []rukpakv1alpha1.BundleDeployment {
274
+ fakeBundleDeployment ("test-bd" , bundleImage ),
275
+ },
276
+ )
269
277
require .NoError (t , err )
270
278
271
279
require .Len (t , installedPackages , 1 )
@@ -285,7 +293,12 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
285
293
defer featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .ForceSemverUpgradeConstraints , false )()
286
294
287
295
const bundleImage = "registry.io/repo/[email protected] "
288
- installedPackages , err := variablesources .MakeInstalledPackageVariables (allBundles , fakeBundleDeployments (bundleImage ))
296
+ installedPackages , err := variablesources .MakeInstalledPackageVariables (
297
+ allBundles ,
298
+ []rukpakv1alpha1.BundleDeployment {
299
+ fakeBundleDeployment ("test-bd" , bundleImage ),
300
+ },
301
+ )
289
302
require .NoError (t , err )
290
303
291
304
require .Len (t , installedPackages , 1 )
@@ -301,7 +314,12 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
301
314
302
315
t .Run ("installed bundle not found" , func (t * testing.T ) {
303
316
const bundleImage = "registry.io/repo/[email protected] "
304
- installedPackages , err := variablesources .MakeInstalledPackageVariables (allBundles , fakeBundleDeployments (bundleImage ))
317
+ installedPackages , err := variablesources .MakeInstalledPackageVariables (
318
+ allBundles ,
319
+ []rukpakv1alpha1.BundleDeployment {
320
+ fakeBundleDeployment ("test-bd" , bundleImage ),
321
+ },
322
+ )
305
323
assert .Nil (t , installedPackages )
306
324
assert .
ErrorContains (
t ,
err ,
`bundleImage "registry.io/repo/[email protected] " not found` )
307
325
})
0 commit comments