8
8
"math/rand"
9
9
"os"
10
10
"reflect"
11
+ "strings"
11
12
"testing"
12
13
"time"
13
14
@@ -588,11 +589,6 @@ func TestListBundles(t *testing.T) {
588
589
store , err := createAndPopulateDB (db )
589
590
require .NoError (t , err )
590
591
591
- var count int
592
- row := db .QueryRow ("SELECT COUNT(*) FROM operatorbundle" )
593
- err = row .Scan (& count )
594
- require .NoError (t , err )
595
-
596
592
expectedDependencies := []* api.Dependency {
597
593
{
598
594
Type : "olm.package" ,
@@ -610,6 +606,14 @@ func TestListBundles(t *testing.T) {
610
606
Type : "olm.gvk" ,
611
607
Value : `{"group":"testprometheus.coreos.com","kind":"testtestprometheus","version":"v1"}` ,
612
608
},
609
+ {
610
+ Type : "olm.gvk" ,
611
+ Value : `{"group":"testapi.coreos.com","kind":"testapi","version":"v1"}` ,
612
+ },
613
+ {
614
+ Type : "olm.gvk" ,
615
+ Value : `{"group":"etcd.database.coreos.com","kind":"EtcdCluster","version":"v1beta2"}` ,
616
+ },
613
617
}
614
618
615
619
dependencies := []* api.Dependency {}
@@ -622,7 +626,7 @@ func TestListBundles(t *testing.T) {
622
626
}
623
627
}
624
628
}
625
- require .Equal (t , count , len (bundles ))
629
+ require .Equal (t , 10 , len (bundles ))
626
630
require .ElementsMatch (t , expectedDependencies , dependencies )
627
631
}
628
632
@@ -705,11 +709,16 @@ func TestDeprecateBundle(t *testing.T) {
705
709
expected : expected {
706
710
err : errors .NewAggregate ([]error {fmt .Errorf ("error deprecating bundle quay.io/test/etcd.0.6.0: %s" , registry .ErrBundleImageNotInDatabase )}),
707
711
remainingBundles : []string {
708
- "quay.io/test/etcd.0.9.0" ,
709
- "quay.io/test/etcd.0.9.2" ,
710
- "quay.io/test/prometheus.0.22.2" ,
711
- "quay.io/test/prometheus.0.14.0" ,
712
- "quay.io/test/prometheus.0.15.0" ,
712
+ "quay.io/test/etcd.0.9.0/alpha" ,
713
+ "quay.io/test/etcd.0.9.0/beta" ,
714
+ "quay.io/test/etcd.0.9.0/stable" ,
715
+ "quay.io/test/etcd.0.9.2/stable" ,
716
+ "quay.io/test/etcd.0.9.2/alpha" ,
717
+ "quay.io/test/prometheus.0.22.2/preview" ,
718
+ "quay.io/test/prometheus.0.15.0/preview" ,
719
+ "quay.io/test/prometheus.0.15.0/stable" ,
720
+ "quay.io/test/prometheus.0.14.0/preview" ,
721
+ "quay.io/test/prometheus.0.14.0/stable" ,
713
722
},
714
723
deprecatedBundles : []string {},
715
724
remainingPkgChannels : pkgChannel {
@@ -735,13 +744,18 @@ func TestDeprecateBundle(t *testing.T) {
735
744
expected : expected {
736
745
err : nil ,
737
746
remainingBundles : []string {
738
- "quay.io/test/etcd.0.9.0" ,
739
- "quay.io/test/etcd.0.9.2" ,
740
- "quay.io/test/prometheus.0.22.2" ,
741
- "quay.io/test/prometheus.0.15.0" ,
747
+ "quay.io/test/etcd.0.9.0/alpha" ,
748
+ "quay.io/test/etcd.0.9.0/beta" ,
749
+ "quay.io/test/etcd.0.9.0/stable" ,
750
+ "quay.io/test/etcd.0.9.2/stable" ,
751
+ "quay.io/test/etcd.0.9.2/alpha" ,
752
+ "quay.io/test/prometheus.0.15.0/preview" ,
753
+ "quay.io/test/prometheus.0.15.0/stable" ,
754
+ "quay.io/test/prometheus.0.22.2/preview" ,
742
755
},
743
756
deprecatedBundles : []string {
744
- "quay.io/test/prometheus.0.15.0" ,
757
+ "quay.io/test/prometheus.0.15.0/preview" ,
758
+ "quay.io/test/prometheus.0.15.0/stable" ,
745
759
},
746
760
remainingPkgChannels : pkgChannel {
747
761
"etcd" : []string {
@@ -766,13 +780,17 @@ func TestDeprecateBundle(t *testing.T) {
766
780
expected : expected {
767
781
err : nil ,
768
782
remainingBundles : []string {
769
- "quay.io/test/etcd.0.9.2" ,
770
- "quay.io/test/prometheus.0.22.2" ,
771
- "quay.io/test/prometheus.0.14.0" ,
772
- "quay.io/test/prometheus.0.15.0" ,
783
+ "quay.io/test/etcd.0.9.2/alpha" ,
784
+ "quay.io/test/etcd.0.9.2/stable" ,
785
+ "quay.io/test/prometheus.0.22.2/preview" ,
786
+ "quay.io/test/prometheus.0.14.0/preview" ,
787
+ "quay.io/test/prometheus.0.14.0/stable" ,
788
+ "quay.io/test/prometheus.0.15.0/preview" ,
789
+ "quay.io/test/prometheus.0.15.0/stable" ,
773
790
},
774
791
deprecatedBundles : []string {
775
- "quay.io/test/etcd.0.9.2" ,
792
+ "quay.io/test/etcd.0.9.2/alpha" ,
793
+ "quay.io/test/etcd.0.9.2/stable" ,
776
794
},
777
795
remainingPkgChannels : pkgChannel {
778
796
"etcd" : []string {
@@ -809,8 +827,9 @@ func TestDeprecateBundle(t *testing.T) {
809
827
require .NoError (t , err )
810
828
var bundlePaths []string
811
829
for _ , bundle := range bundles {
812
- bundlePaths = append (bundlePaths , bundle .BundlePath )
830
+ bundlePaths = append (bundlePaths , strings . Join ([] string { bundle .BundlePath , bundle . ChannelName }, "/" ) )
813
831
}
832
+ fmt .Println ("remaining" , bundlePaths )
814
833
require .ElementsMatch (t , tt .expected .remainingBundles , bundlePaths )
815
834
816
835
// Ensure deprecated bundles match
@@ -820,10 +839,11 @@ func TestDeprecateBundle(t *testing.T) {
820
839
for _ , bundle := range bundles {
821
840
for _ , prop := range bundle .Properties {
822
841
if prop .Type == registry .DeprecatedType && prop .Value == string (deprecatedProperty ) {
823
- deprecatedBundles = append (deprecatedBundles , bundle .BundlePath )
842
+ deprecatedBundles = append (deprecatedBundles , strings . Join ([] string { bundle .BundlePath , bundle . ChannelName }, "/" ) )
824
843
}
825
844
}
826
845
}
846
+ fmt .Println ("deprecated" , deprecatedBundles )
827
847
828
848
require .ElementsMatch (t , tt .expected .deprecatedBundles , deprecatedBundles )
829
849
0 commit comments