@@ -982,7 +982,7 @@ func TestAllCatalogsDisabled(t *testing.T) {
982982 }
983983
984984 getPackage := func (ctx context.Context , cat * catalogd.ClusterCatalog , packageName string ) (* declcfg.DeclarativeConfig , error ) {
985- return genPackage ( pkgName ), nil
985+ panic ( "getPackage should never be called when all catalogs are disabled" )
986986 }
987987
988988 r := CatalogResolver {
@@ -992,7 +992,7 @@ func TestAllCatalogsDisabled(t *testing.T) {
992992 ce := buildFooClusterExtension (pkgName , []string {}, ">=1.0.0" , ocv1alpha1 .UpgradeConstraintPolicyCatalogProvided )
993993 _ , _ , _ , err := r .Resolve (context .Background (), ce , nil )
994994 require .Error (t , err )
995- assert .Contains (t , err .Error (), "no enabled catalogs found" )
995+ assert .Contains (t , err .Error (), "no bundles found for package " )
996996}
997997
998998func TestSomeCatalogsDisabled (t * testing.T ) {
@@ -1032,33 +1032,58 @@ func TestPriorityRespectedWithDisabledCatalogs(t *testing.T) {
10321032 listCatalogs := func (ctx context.Context , options ... client.ListOption ) ([]catalogd.ClusterCatalog , error ) {
10331033 return []catalogd.ClusterCatalog {
10341034 {
1035+ ObjectMeta : metav1.ObjectMeta {
1036+ Name : "enabledCatalog" ,
1037+ },
10351038 Spec : catalogd.ClusterCatalogSpec {
1036- Priority : 1 ,
1039+ Priority : 0 , // Lower priority
10371040 Availability : "Enabled" ,
10381041 },
10391042 },
10401043 {
1044+ ObjectMeta : metav1.ObjectMeta {
1045+ Name : "disabledCatalog" ,
1046+ },
10411047 Spec : catalogd.ClusterCatalogSpec {
1042- Priority : 0 ,
1048+ Priority : 1 , // Higher priority
10431049 Availability : "Disabled" ,
10441050 },
10451051 },
10461052 }, nil
10471053 }
10481054
10491055 getPackage := func (ctx context.Context , cat * catalogd.ClusterCatalog , packageName string ) (* declcfg.DeclarativeConfig , error ) {
1050- return genPackage (pkgName ), nil
1056+ if cat .Spec .Availability == "Disabled" {
1057+ panic ("getPackage should not be called for disabled catalogs" )
1058+ }
1059+ // Enabled catalog returns a lower version
1060+ return & declcfg.DeclarativeConfig {
1061+ Packages : []declcfg.Package {{Name : pkgName }},
1062+ Channels : []declcfg.Channel {
1063+ {
1064+ Package : pkgName ,
1065+ Name : "alpha" ,
1066+ Entries : []declcfg.ChannelEntry {
1067+ {Name : bundleName (pkgName , "1.0.0" )},
1068+ },
1069+ },
1070+ },
1071+ Bundles : []declcfg.Bundle {
1072+ genBundle (pkgName , "1.0.0" ),
1073+ },
1074+ }, nil
10511075 }
10521076
10531077 r := CatalogResolver {
10541078 WalkCatalogsFunc : CatalogWalker (listCatalogs , getPackage ),
10551079 }
10561080
1057- ce := buildFooClusterExtension (pkgName , []string {}, ">=1.0.0 " , ocv1alpha1 .UpgradeConstraintPolicyCatalogProvided )
1081+ ce := buildFooClusterExtension (pkgName , []string {}, "" , ocv1alpha1 .UpgradeConstraintPolicyCatalogProvided )
10581082 gotBundle , gotVersion , _ , err := r .Resolve (context .Background (), ce , nil )
10591083 require .NoError (t , err )
10601084 require .NotNil (t , gotBundle )
1061- require .Equal (t , bsemver .MustParse ("3.0.0" ), * gotVersion )
1085+ require .Equal (t , genBundle (pkgName , "1.0.0" ), * gotBundle )
1086+ require .Equal (t , bsemver .MustParse ("1.0.0" ), * gotVersion )
10621087}
10631088
10641089func TestCatalogWithoutAvailabilityIsEnabled (t * testing.T ) {
0 commit comments