@@ -2063,6 +2063,73 @@ var _ = Describe("Subscription", func() {
2063
2063
}).ShouldNot (Succeed ())
2064
2064
})
2065
2065
})
2066
+
2067
+ When ("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels" , func () {
2068
+ var (
2069
+ teardown func ()
2070
+ )
2071
+
2072
+ BeforeEach (func () {
2073
+ teardown = func () {}
2074
+
2075
+ packages := []registry.PackageManifest {
2076
+ {
2077
+ PackageName : "dependency" ,
2078
+ Channels : []registry.PackageChannel {
2079
+ {Name : "default" , CurrentCSVName : "csv-dependency" },
2080
+ {Name : "nondefault" , CurrentCSVName : "csv-dependency" },
2081
+ },
2082
+ DefaultChannelName : "default" ,
2083
+ },
2084
+ {
2085
+ PackageName : "root" ,
2086
+ Channels : []registry.PackageChannel {
2087
+ {Name : "unimportant" , CurrentCSVName : "csv-root" },
2088
+ },
2089
+ DefaultChannelName : "unimportant" ,
2090
+ },
2091
+ }
2092
+
2093
+ crds := []apiextensions.CustomResourceDefinition {newCRD (genName ("crd-" ))}
2094
+ csvs := []operatorsv1alpha1.ClusterServiceVersion {
2095
+ newCSV ("csv-dependency" , testNamespace , "" , semver .MustParse ("1.0.0" ), crds , nil , nil ),
2096
+ newCSV ("csv-root" , testNamespace , "" , semver .MustParse ("1.0.0" ), nil , crds , nil ),
2097
+ }
2098
+
2099
+ _ , teardown = createInternalCatalogSource (ctx .Ctx ().KubeClient (), ctx .Ctx ().OperatorClient (), "test-catalog" , testNamespace , packages , crds , csvs )
2100
+
2101
+ createSubscriptionForCatalog (ctx .Ctx ().OperatorClient (), testNamespace , "test-subscription" , "test-catalog" , "root" , "unimportant" , "" , operatorsv1alpha1 .ApprovalAutomatic )
2102
+ })
2103
+
2104
+ AfterEach (func () {
2105
+ teardown ()
2106
+ })
2107
+
2108
+ It ("should create a Subscription using the candidate's default channel" , func () {
2109
+ Eventually (func () ([]operatorsv1alpha1.Subscription , error ) {
2110
+ var list operatorsv1alpha1.SubscriptionList
2111
+ if err := ctx .Ctx ().Client ().List (context .TODO (), & list ); err != nil {
2112
+ return nil , err
2113
+ }
2114
+ return list .Items , nil
2115
+ }).Should (ContainElement (WithTransform (
2116
+ func (in operatorsv1alpha1.Subscription ) operatorsv1alpha1.SubscriptionSpec {
2117
+ return operatorsv1alpha1.SubscriptionSpec {
2118
+ CatalogSource : in .Spec .CatalogSource ,
2119
+ CatalogSourceNamespace : in .Spec .CatalogSourceNamespace ,
2120
+ Package : in .Spec .Package ,
2121
+ Channel : in .Spec .Channel ,
2122
+ }
2123
+ },
2124
+ Equal (operatorsv1alpha1.SubscriptionSpec {
2125
+ CatalogSource : "test-catalog" ,
2126
+ CatalogSourceNamespace : testNamespace ,
2127
+ Package : "dependency" ,
2128
+ Channel : "default" ,
2129
+ }),
2130
+ )))
2131
+ })
2132
+ })
2066
2133
})
2067
2134
2068
2135
const (
0 commit comments