Skip to content

Commit 204836e

Browse files
authoredAug 1, 2020
Merge pull request #410 from ecordell/listbundles-broken
fix(query): return bundles in all channels
2 parents e590015 + 166e59d commit 204836e

File tree

3 files changed

+142
-32
lines changed

3 files changed

+142
-32
lines changed
 

‎pkg/registry/populator_test.go

+43-23
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"math/rand"
99
"os"
1010
"reflect"
11+
"strings"
1112
"testing"
1213
"time"
1314

@@ -588,11 +589,6 @@ func TestListBundles(t *testing.T) {
588589
store, err := createAndPopulateDB(db)
589590
require.NoError(t, err)
590591

591-
var count int
592-
row := db.QueryRow("SELECT COUNT(*) FROM operatorbundle")
593-
err = row.Scan(&count)
594-
require.NoError(t, err)
595-
596592
expectedDependencies := []*api.Dependency{
597593
{
598594
Type: "olm.package",
@@ -610,6 +606,14 @@ func TestListBundles(t *testing.T) {
610606
Type: "olm.gvk",
611607
Value: `{"group":"testprometheus.coreos.com","kind":"testtestprometheus","version":"v1"}`,
612608
},
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+
},
613617
}
614618

615619
dependencies := []*api.Dependency{}
@@ -622,7 +626,7 @@ func TestListBundles(t *testing.T) {
622626
}
623627
}
624628
}
625-
require.Equal(t, count, len(bundles))
629+
require.Equal(t, 10, len(bundles))
626630
require.ElementsMatch(t, expectedDependencies, dependencies)
627631
}
628632

@@ -705,11 +709,16 @@ func TestDeprecateBundle(t *testing.T) {
705709
expected: expected{
706710
err: errors.NewAggregate([]error{fmt.Errorf("error deprecating bundle quay.io/test/etcd.0.6.0: %s", registry.ErrBundleImageNotInDatabase)}),
707711
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",
713722
},
714723
deprecatedBundles: []string{},
715724
remainingPkgChannels: pkgChannel{
@@ -735,13 +744,18 @@ func TestDeprecateBundle(t *testing.T) {
735744
expected: expected{
736745
err: nil,
737746
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",
742755
},
743756
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",
745759
},
746760
remainingPkgChannels: pkgChannel{
747761
"etcd": []string{
@@ -766,13 +780,17 @@ func TestDeprecateBundle(t *testing.T) {
766780
expected: expected{
767781
err: nil,
768782
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",
773790
},
774791
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",
776794
},
777795
remainingPkgChannels: pkgChannel{
778796
"etcd": []string{
@@ -809,8 +827,9 @@ func TestDeprecateBundle(t *testing.T) {
809827
require.NoError(t, err)
810828
var bundlePaths []string
811829
for _, bundle := range bundles {
812-
bundlePaths = append(bundlePaths, bundle.BundlePath)
830+
bundlePaths = append(bundlePaths, strings.Join([]string{bundle.BundlePath, bundle.ChannelName}, "/"))
813831
}
832+
fmt.Println("remaining", bundlePaths)
814833
require.ElementsMatch(t, tt.expected.remainingBundles, bundlePaths)
815834

816835
// Ensure deprecated bundles match
@@ -820,10 +839,11 @@ func TestDeprecateBundle(t *testing.T) {
820839
for _, bundle := range bundles {
821840
for _, prop := range bundle.Properties {
822841
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}, "/"))
824843
}
825844
}
826845
}
846+
fmt.Println("deprecated", deprecatedBundles)
827847

828848
require.ElementsMatch(t, tt.expected.deprecatedBundles, deprecatedBundles)
829849

0 commit comments

Comments
 (0)
Please sign in to comment.