@@ -191,85 +191,6 @@ func TestSolveOperators_WithSystemConstraints(t *testing.T) {
191
191
}
192
192
}
193
193
194
- func WithInstalledCSV (sub * v1alpha1.Subscription , csvName string ) * v1alpha1.Subscription {
195
- sub .Status .InstalledCSV = csvName
196
- return sub
197
- }
198
-
199
- func TestSolveOperators_WithFailForward (t * testing.T ) {
200
- const namespace = "test-namespace"
201
- catalog := cache.SourceKey {Name : "test-catalog" , Namespace : namespace }
202
-
203
- packageASubV2 := newSub (namespace , "packageA" , "alpha" , catalog )
204
- APISet := cache.APISet {opregistry.APIKey {Group : "g" , Version : "v" , Kind : "k" , Plural : "ks" }: struct {}{}}
205
-
206
- // packageA provides an API
207
- packageAV1 := genEntry ("packageA.v1" , "0.0.1" , "" , "packageA" , "alpha" , catalog .Name , catalog .Namespace , nil , APISet , nil , "" , false )
208
- packageAV2 := genEntry ("packageA.v2" , "0.0.2" , "packageA.v1" , "packageA" , "alpha" , catalog .Name , catalog .Namespace , nil , APISet , nil , "" , false )
209
- packageAV3 := genEntry ("packageA.v3" , "0.0.3" , "packageA.v2" , "packageA" , "alpha" , catalog .Name , catalog .Namespace , nil , APISet , nil , "" , false )
210
-
211
- existingPackageAV1 := existingOperator (namespace , "packageA.v1" , "packageA" , "alpha" , "" , APISet , nil , nil , nil )
212
- existingPackageAV2 := existingOperator (namespace , "packageA.v2" , "packageA" , "alpha" , "packageA.v1" , APISet , nil , nil , nil )
213
-
214
- testCases := []struct {
215
- title string
216
- expectedOperators []* cache.Entry
217
- csvs []* v1alpha1.ClusterServiceVersion
218
- subs []* v1alpha1.Subscription
219
- snapshotEntries []* cache.Entry
220
- failForwardPredicates []cache.Predicate
221
- err string
222
- }{
223
- {
224
- title : "Resolver fails if v1 and v2 provide the same APIs and v1 is not omitted from the resolver" ,
225
- snapshotEntries : []* cache.Entry {packageAV1 , packageAV2 },
226
- expectedOperators : nil ,
227
- csvs : []* v1alpha1.ClusterServiceVersion {existingPackageAV1 , existingPackageAV2 },
228
- subs : []* v1alpha1.Subscription {WithInstalledCSV (packageASubV2 , existingPackageAV2 .Name )},
229
- err : "provide k (g/v)" ,
230
- },
231
- {
232
- title : "Resolver succeeds if v1 and v2 provide the same APIs and v1 is omitted from the resolver" ,
233
- snapshotEntries : []* cache.Entry {packageAV1 , packageAV2 },
234
- expectedOperators : nil ,
235
- csvs : []* v1alpha1.ClusterServiceVersion {existingPackageAV1 , existingPackageAV2 },
236
- subs : []* v1alpha1.Subscription {WithInstalledCSV (packageASubV2 , existingPackageAV2 .Name )},
237
- failForwardPredicates : []cache.Predicate {cache .Not (cache .CSVNamePredicate ("packageA.v1" ))},
238
- err : "" ,
239
- },
240
- {
241
- title : "Resolver succeeds if v1 and v2 provide the same APIs, v1 is omitted from the resolver, and an upgrade for v2 exists" ,
242
- snapshotEntries : []* cache.Entry {packageAV1 , packageAV2 , packageAV3 },
243
- expectedOperators : []* cache.Entry {packageAV3 },
244
- csvs : []* v1alpha1.ClusterServiceVersion {existingPackageAV1 , existingPackageAV2 },
245
- subs : []* v1alpha1.Subscription {WithInstalledCSV (packageASubV2 , existingPackageAV2 .Name )},
246
- failForwardPredicates : []cache.Predicate {cache .Not (cache .CSVNamePredicate ("packageA.v1" ))},
247
- err : "" ,
248
- },
249
- }
250
-
251
- for _ , testCase := range testCases {
252
- resolver := Resolver {
253
- cache : cache .New (cache.StaticSourceProvider {
254
- catalog : & cache.Snapshot {
255
- Entries : testCase .snapshotEntries ,
256
- },
257
- cache .NewVirtualSourceKey (namespace ): csvSnapshotOrPanic (namespace , testCase .subs , testCase .csvs ... ),
258
- }),
259
- log : logrus .New (),
260
- }
261
- operators , err := resolver .Resolve ([]string {namespace }, testCase .subs , testCase .failForwardPredicates ... )
262
-
263
- if testCase .err != "" {
264
- require .Error (t , err )
265
- require .Containsf (t , err .Error (), testCase .err , "Test %s failed" , testCase .title )
266
- } else {
267
- require .NoErrorf (t , err , "Test %s failed" , testCase .title )
268
- }
269
- require .ElementsMatch (t , testCase .expectedOperators , operators , "Test %s failed" , testCase .title )
270
- }
271
- }
272
-
273
194
func TestDisjointChannelGraph (t * testing.T ) {
274
195
const namespace = "test-namespace"
275
196
catalog := cache.SourceKey {Name : "test-catalog" , Namespace : namespace }
@@ -1521,6 +1442,7 @@ func TestSolveOperators_TransferApiOwnership(t *testing.T) {
1521
1442
key : cache .NewVirtualSourceKey (namespace ),
1522
1443
csvLister : & csvs ,
1523
1444
subLister : fakeSubscriptionLister (p .subs ),
1445
+ ogLister : fakeOperatorGroupLister {},
1524
1446
logger : logger ,
1525
1447
},
1526
1448
}),
0 commit comments