@@ -1000,19 +1000,28 @@ func TestSomeCatalogsDisabled(t *testing.T) {
10001000 listCatalogs := func (ctx context.Context , options ... client.ListOption ) ([]catalogd.ClusterCatalog , error ) {
10011001 return []catalogd.ClusterCatalog {
10021002 {
1003+ ObjectMeta : metav1.ObjectMeta {
1004+ Name : "enabledCatalog" ,
1005+ },
10031006 Spec : catalogd.ClusterCatalogSpec {
1007+ Priority : 1 , // Higher priority
10041008 Availability : "Enabled" ,
10051009 },
10061010 },
10071011 {
1012+ ObjectMeta : metav1.ObjectMeta {
1013+ Name : "disabledCatalog" ,
1014+ },
10081015 Spec : catalogd.ClusterCatalogSpec {
1016+ Priority : 0 , // Lower priority (but disabled)
10091017 Availability : "Disabled" ,
10101018 },
10111019 },
10121020 }, nil
10131021 }
10141022
10151023 getPackage := func (ctx context.Context , cat * catalogd.ClusterCatalog , packageName string ) (* declcfg.DeclarativeConfig , error ) {
1024+ // Only enabled catalog should be processed
10161025 return genPackage (pkgName ), nil
10171026 }
10181027
@@ -1026,53 +1035,3 @@ func TestSomeCatalogsDisabled(t *testing.T) {
10261035 require .NotNil (t , gotBundle )
10271036 require .Equal (t , bsemver .MustParse ("3.0.0" ), * gotVersion )
10281037}
1029-
1030- func TestCatalogWithoutAvailabilityIsEnabled (t * testing.T ) {
1031- pkgName := randPkg ()
1032- listCatalogs := func (ctx context.Context , options ... client.ListOption ) ([]catalogd.ClusterCatalog , error ) {
1033- return []catalogd.ClusterCatalog {
1034- {
1035- Spec : catalogd.ClusterCatalogSpec {
1036- Priority : 1 , // No Availability field set
1037- },
1038- },
1039- {
1040- Spec : catalogd.ClusterCatalogSpec {
1041- Availability : "Disabled" , // This should be skipped
1042- Priority : 2 ,
1043- },
1044- },
1045- }, nil
1046- }
1047-
1048- getPackage := func (ctx context.Context , cat * catalogd.ClusterCatalog , packageName string ) (* declcfg.DeclarativeConfig , error ) {
1049- if cat .Spec .Availability == "" || cat .Spec .Availability == "Enabled" {
1050- return genPackage (pkgName ), nil
1051- }
1052- return & declcfg.DeclarativeConfig {
1053- Packages : []declcfg.Package {{Name : pkgName }},
1054- Channels : []declcfg.Channel {
1055- {
1056- Package : pkgName ,
1057- Name : "alpha" ,
1058- Entries : []declcfg.ChannelEntry {
1059- {Name : bundleName (pkgName , "3.0.0" )},
1060- },
1061- },
1062- },
1063- Bundles : []declcfg.Bundle {
1064- genBundle (pkgName , "3.0.0" ),
1065- },
1066- }, nil
1067- }
1068-
1069- r := CatalogResolver {
1070- WalkCatalogsFunc : CatalogWalker (listCatalogs , getPackage ),
1071- }
1072-
1073- ce := buildFooClusterExtension (pkgName , []string {}, ">=1.0.0" , ocv1alpha1 .UpgradeConstraintPolicyCatalogProvided )
1074- gotBundle , gotVersion , _ , err := r .Resolve (context .Background (), ce , nil )
1075- require .NoError (t , err )
1076- require .NotNil (t , gotBundle )
1077- require .Equal (t , bsemver .MustParse ("3.0.0" ), * gotVersion , "expected version to be 3.0.0, but got %s" , gotVersion )
1078- }
0 commit comments