@@ -1125,19 +1125,19 @@ func TestSyncCatalogSources(t *testing.T) {
1125
1125
1126
1126
func TestSyncResolvingNamespace (t * testing.T ) {
1127
1127
clockFake := utilclocktesting .NewFakeClock (time .Date (2018 , time .January , 26 , 20 , 40 , 0 , 0 , time .UTC ))
1128
+ now := metav1 .NewTime (clockFake .Now ())
1128
1129
testNamespace := "testNamespace"
1129
1130
1130
1131
type fields struct {
1131
- clientOptions []clientfake.Option
1132
- sourcesLastUpdate metav1.Time
1133
- resolveErr error
1134
- existingOLMObjs []runtime.Object
1135
- existingObjects []runtime.Object
1132
+ clientOptions []clientfake.Option
1133
+ resolveErr error
1134
+ existingOLMObjs []runtime.Object
1136
1135
}
1137
1136
tests := []struct {
1138
- name string
1139
- fields fields
1140
- wantErr error
1137
+ name string
1138
+ fields fields
1139
+ wantSubscriptions []* v1alpha1.Subscription
1140
+ wantErr error
1141
1141
}{
1142
1142
{
1143
1143
name : "NoError" ,
@@ -1164,6 +1164,26 @@ func TestSyncResolvingNamespace(t *testing.T) {
1164
1164
},
1165
1165
},
1166
1166
},
1167
+ wantSubscriptions : []* v1alpha1.Subscription {
1168
+ {
1169
+ TypeMeta : metav1.TypeMeta {
1170
+ Kind : v1alpha1 .SubscriptionKind ,
1171
+ APIVersion : v1alpha1 .SchemeGroupVersion .String (),
1172
+ },
1173
+ ObjectMeta : metav1.ObjectMeta {
1174
+ Name : "sub" ,
1175
+ Namespace : testNamespace ,
1176
+ },
1177
+ Spec : & v1alpha1.SubscriptionSpec {
1178
+ CatalogSource : "src" ,
1179
+ CatalogSourceNamespace : testNamespace ,
1180
+ },
1181
+ Status : v1alpha1.SubscriptionStatus {
1182
+ CurrentCSV : "" ,
1183
+ State : "" ,
1184
+ },
1185
+ },
1186
+ },
1167
1187
},
1168
1188
{
1169
1189
name : "NotSatisfiableError" ,
@@ -1196,6 +1216,35 @@ func TestSyncResolvingNamespace(t *testing.T) {
1196
1216
},
1197
1217
},
1198
1218
},
1219
+ wantSubscriptions : []* v1alpha1.Subscription {
1220
+ {
1221
+ TypeMeta : metav1.TypeMeta {
1222
+ Kind : v1alpha1 .SubscriptionKind ,
1223
+ APIVersion : v1alpha1 .SchemeGroupVersion .String (),
1224
+ },
1225
+ ObjectMeta : metav1.ObjectMeta {
1226
+ Name : "sub" ,
1227
+ Namespace : testNamespace ,
1228
+ },
1229
+ Spec : & v1alpha1.SubscriptionSpec {
1230
+ CatalogSource : "src" ,
1231
+ CatalogSourceNamespace : testNamespace ,
1232
+ },
1233
+ Status : v1alpha1.SubscriptionStatus {
1234
+ CurrentCSV : "" ,
1235
+ State : "" ,
1236
+ Conditions : []v1alpha1.SubscriptionCondition {
1237
+ {
1238
+ Type : v1alpha1 .SubscriptionResolutionFailed ,
1239
+ Reason : "ConstraintsNotSatisfiable" ,
1240
+ Message : "constraints not satisfiable: something" ,
1241
+ Status : corev1 .ConditionTrue ,
1242
+ },
1243
+ },
1244
+ LastUpdated : now ,
1245
+ },
1246
+ },
1247
+ },
1199
1248
},
1200
1249
{
1201
1250
name : "OtherError" ,
@@ -1232,6 +1281,35 @@ func TestSyncResolvingNamespace(t *testing.T) {
1232
1281
},
1233
1282
resolveErr : fmt .Errorf ("some error" ),
1234
1283
},
1284
+ wantSubscriptions : []* v1alpha1.Subscription {
1285
+ {
1286
+ TypeMeta : metav1.TypeMeta {
1287
+ Kind : v1alpha1 .SubscriptionKind ,
1288
+ APIVersion : v1alpha1 .SchemeGroupVersion .String (),
1289
+ },
1290
+ ObjectMeta : metav1.ObjectMeta {
1291
+ Name : "sub" ,
1292
+ Namespace : testNamespace ,
1293
+ },
1294
+ Spec : & v1alpha1.SubscriptionSpec {
1295
+ CatalogSource : "src" ,
1296
+ CatalogSourceNamespace : testNamespace ,
1297
+ },
1298
+ Status : v1alpha1.SubscriptionStatus {
1299
+ CurrentCSV : "" ,
1300
+ State : "" ,
1301
+ Conditions : []v1alpha1.SubscriptionCondition {
1302
+ {
1303
+ Type : v1alpha1 .SubscriptionResolutionFailed ,
1304
+ Reason : "ErrorPreventedResolution" ,
1305
+ Message : "some error" ,
1306
+ Status : corev1 .ConditionTrue ,
1307
+ },
1308
+ },
1309
+ LastUpdated : now ,
1310
+ },
1311
+ },
1312
+ },
1235
1313
wantErr : fmt .Errorf ("some error" ),
1236
1314
},
1237
1315
}
@@ -1241,7 +1319,7 @@ func TestSyncResolvingNamespace(t *testing.T) {
1241
1319
ctx , cancel := context .WithCancel (context .TODO ())
1242
1320
defer cancel ()
1243
1321
1244
- o , err := NewFakeOperator (ctx , testNamespace , []string {testNamespace }, withClock (clockFake ), withClientObjs (tt .fields .existingOLMObjs ... ), withK8sObjs ( tt . fields . existingObjects ... ), withFakeClientOptions (tt .fields .clientOptions ... ))
1322
+ o , err := NewFakeOperator (ctx , testNamespace , []string {testNamespace }, withClock (clockFake ), withClientObjs (tt .fields .existingOLMObjs ... ), withFakeClientOptions (tt .fields .clientOptions ... ))
1245
1323
require .NoError (t , err )
1246
1324
1247
1325
o .reconciler = & fakes.FakeRegistryReconcilerFactory {
@@ -1254,7 +1332,6 @@ func TestSyncResolvingNamespace(t *testing.T) {
1254
1332
},
1255
1333
}
1256
1334
1257
- o .sourcesLastUpdate .Set (tt .fields .sourcesLastUpdate .Time )
1258
1335
o .resolver = & fakes.FakeStepResolver {
1259
1336
ResolveStepsStub : func (string ) ([]* v1alpha1.Step , []v1alpha1.BundleLookup , []* v1alpha1.Subscription , error ) {
1260
1337
return nil , nil , nil , tt .fields .resolveErr
@@ -1273,6 +1350,12 @@ func TestSyncResolvingNamespace(t *testing.T) {
1273
1350
} else {
1274
1351
require .NoError (t , err )
1275
1352
}
1353
+
1354
+ for _ , s := range tt .wantSubscriptions {
1355
+ fetched , err := o .client .OperatorsV1alpha1 ().Subscriptions (testNamespace ).Get (context .TODO (), s .GetName (), metav1.GetOptions {})
1356
+ require .NoError (t , err )
1357
+ require .Equal (t , s , fetched )
1358
+ }
1276
1359
})
1277
1360
}
1278
1361
}
0 commit comments