@@ -2134,6 +2134,73 @@ var _ = Describe("Subscription", func() {
2134
2134
}).ShouldNot (Succeed ())
2135
2135
})
2136
2136
})
2137
+
2138
+ When ("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels" , func () {
2139
+ var (
2140
+ teardown func ()
2141
+ )
2142
+
2143
+ BeforeEach (func () {
2144
+ teardown = func () {}
2145
+
2146
+ packages := []registry.PackageManifest {
2147
+ {
2148
+ PackageName : "dependency" ,
2149
+ Channels : []registry.PackageChannel {
2150
+ {Name : "default" , CurrentCSVName : "csv-dependency" },
2151
+ {Name : "nondefault" , CurrentCSVName : "csv-dependency" },
2152
+ },
2153
+ DefaultChannelName : "default" ,
2154
+ },
2155
+ {
2156
+ PackageName : "root" ,
2157
+ Channels : []registry.PackageChannel {
2158
+ {Name : "unimportant" , CurrentCSVName : "csv-root" },
2159
+ },
2160
+ DefaultChannelName : "unimportant" ,
2161
+ },
2162
+ }
2163
+
2164
+ crds := []apiextensions.CustomResourceDefinition {newCRD (genName ("crd-" ))}
2165
+ csvs := []operatorsv1alpha1.ClusterServiceVersion {
2166
+ newCSV ("csv-dependency" , testNamespace , "" , semver .MustParse ("1.0.0" ), crds , nil , nil ),
2167
+ newCSV ("csv-root" , testNamespace , "" , semver .MustParse ("1.0.0" ), nil , crds , nil ),
2168
+ }
2169
+
2170
+ _ , teardown = createInternalCatalogSource (ctx .Ctx ().KubeClient (), ctx .Ctx ().OperatorClient (), "test-catalog" , testNamespace , packages , crds , csvs )
2171
+
2172
+ createSubscriptionForCatalog (ctx .Ctx ().OperatorClient (), testNamespace , "test-subscription" , "test-catalog" , "root" , "unimportant" , "" , operatorsv1alpha1 .ApprovalAutomatic )
2173
+ })
2174
+
2175
+ AfterEach (func () {
2176
+ teardown ()
2177
+ })
2178
+
2179
+ It ("should create a Subscription using the candidate's default channel" , func () {
2180
+ Eventually (func () ([]operatorsv1alpha1.Subscription , error ) {
2181
+ var list operatorsv1alpha1.SubscriptionList
2182
+ if err := ctx .Ctx ().Client ().List (context .TODO (), & list ); err != nil {
2183
+ return nil , err
2184
+ }
2185
+ return list .Items , nil
2186
+ }).Should (ContainElement (WithTransform (
2187
+ func (in operatorsv1alpha1.Subscription ) operatorsv1alpha1.SubscriptionSpec {
2188
+ return operatorsv1alpha1.SubscriptionSpec {
2189
+ CatalogSource : in .Spec .CatalogSource ,
2190
+ CatalogSourceNamespace : in .Spec .CatalogSourceNamespace ,
2191
+ Package : in .Spec .Package ,
2192
+ Channel : in .Spec .Channel ,
2193
+ }
2194
+ },
2195
+ Equal (operatorsv1alpha1.SubscriptionSpec {
2196
+ CatalogSource : "test-catalog" ,
2197
+ CatalogSourceNamespace : testNamespace ,
2198
+ Package : "dependency" ,
2199
+ Channel : "default" ,
2200
+ }),
2201
+ )))
2202
+ })
2203
+ })
2137
2204
})
2138
2205
2139
2206
const (
0 commit comments