@@ -23,8 +23,16 @@ func TestNewNamespaceSourceQuerier(t *testing.T) {
23
23
nonEmptySources := map [CatalogKey ]client.Interface {
24
24
CatalogKey {"test" , "ns" }: & fakes.FakeInterface {},
25
25
}
26
+
27
+ emptyClients := map [CatalogKey ]* client.Client {}
28
+ nonEmptyClients := map [CatalogKey ]* client.Client {
29
+ CatalogKey {"test" , "ns" }: & client.Client {
30
+ Registry : & fakes.FakeRegistryClient {},
31
+ },
32
+ }
26
33
type args struct {
27
34
sources map [CatalogKey ]client.Interface
35
+ clients map [CatalogKey ]* client.Client
28
36
}
29
37
tests := []struct {
30
38
name string
@@ -35,34 +43,38 @@ func TestNewNamespaceSourceQuerier(t *testing.T) {
35
43
name : "nil" ,
36
44
args : args {
37
45
sources : nil ,
46
+ clients : nil ,
38
47
},
39
- want : & NamespaceSourceQuerier {sources : nil },
48
+ want : & NamespaceSourceQuerier {sources : nil , clients : nil },
40
49
},
41
50
{
42
51
name : "empty" ,
43
52
args : args {
44
53
sources : emptySources ,
54
+ clients : emptyClients ,
45
55
},
46
- want : & NamespaceSourceQuerier {sources : emptySources },
56
+ want : & NamespaceSourceQuerier {sources : emptySources , clients : emptyClients },
47
57
},
48
58
{
49
59
name : "nonEmpty" ,
50
60
args : args {
51
61
sources : nonEmptySources ,
62
+ clients : nonEmptyClients ,
52
63
},
53
- want : & NamespaceSourceQuerier {sources : nonEmptySources },
64
+ want : & NamespaceSourceQuerier {sources : nonEmptySources , clients : nonEmptyClients },
54
65
},
55
66
}
56
67
for _ , tt := range tests {
57
68
t .Run (tt .name , func (t * testing.T ) {
58
- require .Equal (t , NewNamespaceSourceQuerier (tt .args .sources ), tt .want )
69
+ require .Equal (t , NewNamespaceSourceQuerier (tt .args .sources , tt . args . clients ), tt .want )
59
70
})
60
71
}
61
72
}
62
73
63
74
func TestNamespaceSourceQuerier_Queryable (t * testing.T ) {
64
75
type fields struct {
65
76
sources map [CatalogKey ]client.Interface
77
+ clients map [CatalogKey ]* client.Client
66
78
}
67
79
tests := []struct {
68
80
name string
@@ -73,13 +85,15 @@ func TestNamespaceSourceQuerier_Queryable(t *testing.T) {
73
85
name : "nil" ,
74
86
fields : fields {
75
87
sources : nil ,
88
+ clients : nil ,
76
89
},
77
90
error : fmt .Errorf ("no catalog sources available" ),
78
91
},
79
92
{
80
93
name : "empty" ,
81
94
fields : fields {
82
95
sources : map [CatalogKey ]client.Interface {},
96
+ clients : map [CatalogKey ]* client.Client {},
83
97
},
84
98
error : fmt .Errorf ("no catalog sources available" ),
85
99
},
@@ -89,6 +103,11 @@ func TestNamespaceSourceQuerier_Queryable(t *testing.T) {
89
103
sources : map [CatalogKey ]client.Interface {
90
104
CatalogKey {"test" , "ns" }: & fakes.FakeInterface {},
91
105
},
106
+ clients : map [CatalogKey ]* client.Client {
107
+ CatalogKey {"test" , "ns" }: & client.Client {
108
+ Registry : & fakes.FakeRegistryClient {},
109
+ },
110
+ },
92
111
},
93
112
error : nil ,
94
113
},
@@ -218,6 +237,7 @@ func TestNamespaceSourceQuerier_FindProvider(t *testing.T) {
218
237
func TestNamespaceSourceQuerier_FindPackage (t * testing.T ) {
219
238
initialSource := fakes.FakeInterface {}
220
239
otherSource := fakes.FakeInterface {}
240
+ clients := map [CatalogKey ]* client.Client {}
221
241
initalBundle := & api.Bundle {CsvName : "test" , PackageName : "testPkg" , ChannelName : "testChannel" }
222
242
startingBundle := & api.Bundle {CsvName : "starting-test" , PackageName : "testPkg" , ChannelName : "testChannel" }
223
243
otherBundle := & api.Bundle {CsvName : "other" , PackageName : "otherPkg" , ChannelName : "otherChannel" }
@@ -248,6 +268,7 @@ func TestNamespaceSourceQuerier_FindPackage(t *testing.T) {
248
268
249
269
type fields struct {
250
270
sources map [CatalogKey ]client.Interface
271
+ clients map [CatalogKey ]* client.Client
251
272
}
252
273
type args struct {
253
274
pkgName string
@@ -268,37 +289,37 @@ func TestNamespaceSourceQuerier_FindPackage(t *testing.T) {
268
289
}{
269
290
{
270
291
name : "Initial/Found" ,
271
- fields : fields {sources : sources },
292
+ fields : fields {sources : sources , clients : clients },
272
293
args : args {"test" , "testChannel" , "" , CatalogKey {"initial" , "ns" }},
273
294
out : out {bundle : initalBundle , key : & initialKey , err : nil },
274
295
},
275
296
{
276
297
name : "Initial/CatalogNotFound" ,
277
- fields : fields {sources : sources },
298
+ fields : fields {sources : sources , clients : clients },
278
299
args : args {"test" , "testChannel" , "" , CatalogKey {"absent" , "found" }},
279
300
out : out {bundle : nil , key : nil , err : fmt .Errorf ("CatalogSource {absent found} not found" )},
280
301
},
281
302
{
282
303
name : "Initial/StartingCSVFound" ,
283
- fields : fields {sources : sources },
304
+ fields : fields {sources : sources , clients : clients },
284
305
args : args {"test" , "testChannel" , "starting-test" , CatalogKey {"initial" , "ns" }},
285
306
out : out {bundle : startingBundle , key : & initialKey , err : nil },
286
307
},
287
308
{
288
309
name : "Initial/StartingCSVNotFound" ,
289
- fields : fields {sources : sources },
310
+ fields : fields {sources : sources , clients : clients },
290
311
args : args {"test" , "testChannel" , "non-existent" , CatalogKey {"initial" , "ns" }},
291
312
out : out {bundle : nil , key : nil , err : fmt .Errorf ("not found" )},
292
313
},
293
314
{
294
315
name : "Other/Found" ,
295
- fields : fields {sources : sources },
316
+ fields : fields {sources : sources , clients : clients },
296
317
args : args {"other" , "testChannel" , "" , CatalogKey {"" , "" }},
297
318
out : out {bundle : otherBundle , key : & otherKey , err : nil },
298
319
},
299
320
{
300
321
name : "NotFound" ,
301
- fields : fields {sources : sources },
322
+ fields : fields {sources : sources , clients : clients },
302
323
args : args {"nope" , "not" , "" , CatalogKey {"" , "" }},
303
324
out : out {bundle : nil , err : fmt .Errorf ("nope/not not found in any available CatalogSource" )},
304
325
},
@@ -307,6 +328,7 @@ func TestNamespaceSourceQuerier_FindPackage(t *testing.T) {
307
328
t .Run (tt .name , func (t * testing.T ) {
308
329
q := & NamespaceSourceQuerier {
309
330
sources : tt .fields .sources ,
331
+ clients : tt .fields .clients ,
310
332
}
311
333
var got * api.Bundle
312
334
var key * CatalogKey
@@ -330,6 +352,7 @@ func TestNamespaceSourceQuerier_FindReplacement(t *testing.T) {
330
352
replacementSource := fakes.FakeInterface {}
331
353
replacementAndLatestSource := fakes.FakeInterface {}
332
354
replacementAndNoAnnotationLatestSource := fakes.FakeInterface {}
355
+ clients := map [CatalogKey ]* client.Client {}
333
356
334
357
latestVersion := semver .MustParse ("1.0.0-1556661308" )
335
358
csv := v1alpha1.ClusterServiceVersion {
@@ -417,6 +440,7 @@ func TestNamespaceSourceQuerier_FindReplacement(t *testing.T) {
417
440
418
441
type fields struct {
419
442
sources map [CatalogKey ]client.Interface
443
+ clients map [CatalogKey ]* client.Client
420
444
}
421
445
type args struct {
422
446
currentVersion * semver.Version
@@ -438,43 +462,43 @@ func TestNamespaceSourceQuerier_FindReplacement(t *testing.T) {
438
462
}{
439
463
{
440
464
name : "FindsLatestInPrimaryCatalog" ,
441
- fields : fields {sources : sources },
465
+ fields : fields {sources : sources , clients : clients },
442
466
args : args {& startVersion , "testPkg" , "testChannel" , "test.v1" , initialKey },
443
467
out : out {bundle : latestBundle , key : & initialKey , err : nil },
444
468
},
445
469
{
446
470
name : "FindsLatestInSecondaryCatalog" ,
447
- fields : fields {sources : sources },
471
+ fields : fields {sources : sources , clients : clients },
448
472
args : args {& startVersion , "testPkg" , "testChannel" , "test.v1" , otherKey },
449
473
out : out {bundle : latestBundle , key : & otherKey , err : nil },
450
474
},
451
475
{
452
476
name : "PrefersLatestToReplaced/SameCatalog" ,
453
- fields : fields {sources : sources },
477
+ fields : fields {sources : sources , clients : clients },
454
478
args : args {& startVersion , "testPkg" , "testChannel" , "test.v1" , replacementAndLatestKey },
455
479
out : out {bundle : latestBundle , key : & replacementAndLatestKey , err : nil },
456
480
},
457
481
{
458
482
name : "PrefersLatestToReplaced/OtherCatalog" ,
459
- fields : fields {sources : sources },
483
+ fields : fields {sources : sources , clients : clients },
460
484
args : args {& startVersion , "testPkg" , "testChannel" , "test.v1" , initialKey },
461
485
out : out {bundle : latestBundle , key : & initialKey , err : nil },
462
486
},
463
487
{
464
488
name : "IgnoresLatestWithoutAnnotation" ,
465
- fields : fields {sources : sources },
489
+ fields : fields {sources : sources , clients : clients },
466
490
args : args {& startVersion , "testPkg" , "testChannel" , "test.v1" , replacementAndNoAnnotationLatestKey },
467
491
out : out {bundle : nextBundle , key : & replacementAndNoAnnotationLatestKey , err : nil },
468
492
},
469
493
{
470
494
name : "IgnoresLatestNotInRange" ,
471
- fields : fields {sources : sources },
495
+ fields : fields {sources : sources , clients : clients },
472
496
args : args {& notInRange , "testPkg" , "testChannel" , "test.v1" , replacementAndLatestKey },
473
497
out : out {bundle : nextBundle , key : & replacementAndLatestKey , err : nil },
474
498
},
475
499
{
476
500
name : "IgnoresLatestAtLatest" ,
477
- fields : fields {sources : sources },
501
+ fields : fields {sources : sources , clients : clients },
478
502
args : args {& latestVersion , "testPkg" , "testChannel" , "test.v1" , otherKey },
479
503
out : out {bundle : nil , key : nil , err : nil },
480
504
},
@@ -483,6 +507,7 @@ func TestNamespaceSourceQuerier_FindReplacement(t *testing.T) {
483
507
t .Run (tt .name , func (t * testing.T ) {
484
508
q := & NamespaceSourceQuerier {
485
509
sources : tt .fields .sources ,
510
+ clients : tt .fields .clients ,
486
511
}
487
512
var got * api.Bundle
488
513
var key * CatalogKey
0 commit comments