@@ -121,6 +121,10 @@ func TestQuerierForImage(t *testing.T) {
121121 Type : "olm.gvk" ,
122122 Value : `{"group":"testapi.coreos.com","kind":"testapi","type":"olm.gvk","version":"v1"}` ,
123123 },
124+ {
125+ Type : "olm.gvk" ,
126+ Value : `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","type":"olm.gvk","version":"v1beta2"}` ,
127+ },
124128 },
125129 ProvidedApis : []* api.GroupVersionKind {
126130 {Group : "etcd.database.coreos.com" , Version : "v1beta2" , Kind : "EtcdCluster" , Plural : "etcdclusters" },
@@ -403,6 +407,10 @@ func TestQuerierForDependencies(t *testing.T) {
403407 Type : "olm.gvk" ,
404408 Value : `{"group":"testapi.coreos.com","kind":"testapi","type":"olm.gvk","version":"v1"}` ,
405409 },
410+ {
411+ Type : "olm.gvk" ,
412+ Value : `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","type":"olm.gvk","version":"v1beta2"}` ,
413+ },
406414 }
407415
408416 type operatorbundle struct {
@@ -441,6 +449,11 @@ func TestListBundles(t *testing.T) {
441449 store , err := createAndPopulateDB (db )
442450 require .NoError (t , err )
443451
452+ var count int
453+ row := db .QueryRow ("SELECT COUNT(*) FROM operatorbundle" )
454+ err = row .Scan (& count )
455+ require .NoError (t , err )
456+
444457 expectedDependencies := []* api.Dependency {
445458 {
446459 Type : "olm.package" ,
@@ -450,15 +463,23 @@ func TestListBundles(t *testing.T) {
450463 Type : "olm.gvk" ,
451464 Value : `{"group":"testapi.coreos.com","kind":"testapi","type":"olm.gvk","version":"v1"}` ,
452465 },
466+ {
467+ Type : "olm.gvk" ,
468+ Value : `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","type":"olm.gvk","version":"v1beta2"}` ,
469+ },
453470 }
454471
455472 dependencies := []* api.Dependency {}
456473 bundles , err := store .ListBundles (context .TODO ())
457474 require .NoError (t , err )
458475 for _ , b := range bundles {
459- dep := b .Dependencies
460- dependencies = append (dependencies , dep ... )
476+ for _ , d := range b .Dependencies {
477+ if d .GetType () != "" {
478+ dependencies = append (dependencies , d )
479+ }
480+ }
461481 }
482+ require .Equal (t , count , len (bundles ))
462483 require .ElementsMatch (t , expectedDependencies , dependencies )
463484}
464485
@@ -477,7 +498,7 @@ func CheckInvariants(t *testing.T, db *sql.DB) {
477498func CheckChannelHeadsHaveDescriptions (t * testing.T , db * sql.DB ) {
478499 // check channel heads have csv / bundle
479500 rows , err := db .Query (`
480- select operatorbundle.name,length(operatorbundle.csv),length(operatorbundle.bundle) from operatorbundle
501+ select operatorbundle.name,length(operatorbundle.csv),length(operatorbundle.bundle) from operatorbundle
481502 join channel on channel.head_operatorbundle_name = operatorbundle.name` )
482503 require .NoError (t , err )
483504
@@ -496,7 +517,7 @@ func CheckChannelHeadsHaveDescriptions(t *testing.T, db *sql.DB) {
496517func CheckBundlesHaveContentsIfNoPath (t * testing.T , db * sql.DB ) {
497518 // check that any bundle entry has csv/bundle content unpacked if there is no bundlepath
498519 rows , err := db .Query (`
499- select name,length(csv),length(bundle) from operatorbundle
520+ select name,length(csv),length(bundle) from operatorbundle
500521 where bundlepath="" or bundlepath=null` )
501522 require .NoError (t , err )
502523
@@ -510,4 +531,4 @@ func CheckBundlesHaveContentsIfNoPath(t *testing.T, db *sql.DB) {
510531 require .NotZero (t , csvlen .Int64 , "length of csv for %s should not be zero, it has no bundle path" , name .String )
511532 require .NotZero (t , bundlelen .Int64 , "length of bundle for %s should not be zero, it has no bundle path" , name .String )
512533 }
513- }
534+ }
0 commit comments