@@ -12,7 +12,6 @@ import (
12
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
13
"k8s.io/apimachinery/pkg/labels"
14
14
"k8s.io/apimachinery/pkg/util/rand"
15
- "k8s.io/apimachinery/pkg/util/sets"
16
15
featuregatetesting "k8s.io/component-base/featuregate/testing"
17
16
"k8s.io/utils/ptr"
18
17
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -262,60 +261,25 @@ func TestPackageVariationsBetweenCatalogs(t *testing.T) {
262
261
}
263
262
r := CatalogResolver {WalkCatalogsFunc : w .WalkCatalogs }
264
263
265
- t .Run ("always prefer non-deprecated when versions match" , func (t * testing.T ) {
266
- for i := 0 ; i < 100 ; i ++ {
267
- // When the same version exists in both catalogs, we prefer the non-deprecated one.
268
- ce := buildFooClusterExtension (pkgName , "" , ">=1.0.0 <=1.0.1" , ocv1alpha1 .UpgradeConstraintPolicyEnforce )
269
- gotBundle , gotVersion , gotDeprecation , err := r .Resolve (context .Background (), ce , nil )
270
- require .NoError (t , err )
271
- assert .Equal (t , genBundle (pkgName , "1.0.1" ).Name , gotBundle .Name )
272
- assert .Equal (t , bsemver .MustParse ("1.0.1" ), * gotVersion )
273
- assert .Nil (t , gotDeprecation )
274
- }
275
- })
276
-
277
264
t .Run ("when catalog b has a newer version that matches the range" , func (t * testing.T ) {
278
- // When one version exists in one catalog but not the other, we prefer the one that exists.
279
265
ce := buildFooClusterExtension (pkgName , "" , ">=1.0.0 <=1.0.3" , ocv1alpha1 .UpgradeConstraintPolicyEnforce )
280
266
gotBundle , gotVersion , gotDeprecation , err := r .Resolve (context .Background (), ce , nil )
281
- require .NoError (t , err )
282
- assert .Equal (t , genBundle ( pkgName , "1.0.3" ). Name , gotBundle . Name )
283
- assert .Equal (t , genImgRef ( "catalog-b" , gotBundle . Name ), gotBundle . Image )
284
- assert .Equal (t , bsemver . MustParse ( "1.0.3" ), * gotVersion )
285
- assert .Equal ( t , ptr . To ( packageDeprecation ( pkgName )) , gotDeprecation )
267
+ require .Error (t , err )
268
+ assert .ErrorContains (t , err , "found in multiple catalogs: [b c]" )
269
+ assert .Nil (t , gotBundle )
270
+ assert .Nil (t , gotVersion )
271
+ assert .Nil ( t , gotDeprecation )
286
272
})
287
273
288
274
t .Run ("when catalog c has a newer version that matches the range" , func (t * testing.T ) {
289
275
ce := buildFooClusterExtension (pkgName , "" , ">=0.1.0 <1.0.0" , ocv1alpha1 .UpgradeConstraintPolicyEnforce )
290
276
gotBundle , gotVersion , gotDeprecation , err := r .Resolve (context .Background (), ce , nil )
291
- require .NoError (t , err )
292
- assert .Equal (t , genBundle ( pkgName , "0.1.1" ). Name , gotBundle . Name )
293
- assert .Equal (t , genImgRef ( "catalog-c" , gotBundle . Name ), gotBundle . Image )
294
- assert .Equal (t , bsemver . MustParse ( "0.1.1" ), * gotVersion )
277
+ require .Error (t , err )
278
+ assert .ErrorContains (t , err , "found in multiple catalogs: [b c]" )
279
+ assert .Nil (t , gotBundle )
280
+ assert .Nil (t , gotVersion )
295
281
assert .Nil (t , gotDeprecation )
296
282
})
297
-
298
- t .Run ("when there is ambiguity between catalogs" , func (t * testing.T ) {
299
- // When there is no way to disambiguate between two versions, the choice is undefined.
300
- foundImages := sets .New [string ]()
301
- foundDeprecations := sets .New [* declcfg.Deprecation ]()
302
- for i := 0 ; i < 100 ; i ++ {
303
- ce := buildFooClusterExtension (pkgName , "" , "0.1.0" , ocv1alpha1 .UpgradeConstraintPolicyEnforce )
304
- gotBundle , gotVersion , gotDeprecation , err := r .Resolve (context .Background (), ce , nil )
305
- require .NoError (t , err )
306
- assert .Equal (t , genBundle (pkgName , "0.1.0" ).Name , gotBundle .Name )
307
- assert .Equal (t , bsemver .MustParse ("0.1.0" ), * gotVersion )
308
- foundImages .Insert (gotBundle .Image )
309
- foundDeprecations .Insert (gotDeprecation )
310
- }
311
- assert .ElementsMatch (t , []string {
312
- genImgRef ("catalog-b" , bundleName (pkgName , "0.1.0" )),
313
- genImgRef ("catalog-c" , bundleName (pkgName , "0.1.0" )),
314
- }, foundImages .UnsortedList ())
315
-
316
- assert .Contains (t , foundDeprecations , (* declcfg .Deprecation )(nil ))
317
- assert .Contains (t , foundDeprecations , ptr .To (packageDeprecation (pkgName )))
318
- })
319
283
}
320
284
321
285
func TestUpgradeFoundLegacy (t * testing.T ) {
0 commit comments