Skip to content

Commit dd39ba1

Browse files
committedJul 2, 2019
fix(query): return all channels when querying
previously this was returning a maximum of 2 channels
1 parent febd1bd commit dd39ba1

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed
 

‎manifests/etcd/etcd.package.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ channels:
44
currentCSV: etcdoperator.v0.9.2
55
- name: beta
66
currentCSV: etcdoperator.v0.9.0
7+
- name: stable
8+
currentCSV: etcdoperator.v0.9.2
79
defaultChannel: alpha

‎pkg/server/server_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ func TestGetPackage(t *testing.T) {
110110
Name: "beta",
111111
CsvName: "etcdoperator.v0.9.0",
112112
},
113+
{
114+
Name: "stable",
115+
CsvName: "etcdoperator.v0.9.2",
116+
},
113117
},
114118
DefaultChannelName: "alpha",
115119
}
@@ -198,6 +202,12 @@ func TestGetChannelEntriesThatReplace(t *testing.T) {
198202
BundleName: "etcdoperator.v0.9.0",
199203
Replaces: "etcdoperator.v0.6.1",
200204
},
205+
{
206+
PackageName: "etcd",
207+
ChannelName: "stable",
208+
BundleName: "etcdoperator.v0.9.0",
209+
Replaces: "etcdoperator.v0.6.1",
210+
},
201211
}
202212

203213
require.ElementsMatch(t, expected, channelEntries)
@@ -310,6 +320,30 @@ func TestGetChannelEntriesThatProvide(t *testing.T) {
310320
BundleName: "etcdoperator.v0.9.0",
311321
Replaces: "etcdoperator.v0.6.1",
312322
},
323+
{
324+
PackageName: "etcd",
325+
ChannelName: "stable",
326+
BundleName: "etcdoperator.v0.6.1",
327+
Replaces: "",
328+
},
329+
{
330+
PackageName: "etcd",
331+
ChannelName: "stable",
332+
BundleName: "etcdoperator.v0.9.0",
333+
Replaces: "etcdoperator.v0.6.1",
334+
},
335+
{
336+
PackageName: "etcd",
337+
ChannelName: "stable",
338+
BundleName: "etcdoperator.v0.9.2",
339+
Replaces: "etcdoperator.v0.9.1",
340+
},
341+
{
342+
PackageName: "etcd",
343+
ChannelName: "stable",
344+
BundleName: "etcdoperator.v0.9.2",
345+
Replaces: "etcdoperator.v0.9.0",
346+
},
313347
}
314348

315349
require.ElementsMatch(t, expected, channelEntries)
@@ -355,6 +389,12 @@ func TestGetLatestChannelEntriesThatProvide(t *testing.T) {
355389
BundleName: "etcdoperator.v0.9.0",
356390
Replaces: "etcdoperator.v0.6.1",
357391
},
392+
{
393+
PackageName: "etcd",
394+
ChannelName: "stable",
395+
BundleName: "etcdoperator.v0.9.2",
396+
Replaces: "etcdoperator.v0.9.0",
397+
},
358398
}
359399

360400
require.ElementsMatch(t, expected, channelEntries)

‎pkg/sqlite/directory_test.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func TestQuerierForDirectory(t *testing.T) {
5151
Name: "beta",
5252
CurrentCSVName: "etcdoperator.v0.9.0",
5353
},
54+
{
55+
Name: "stable",
56+
CurrentCSVName: "etcdoperator.v0.9.2",
57+
},
5458
},
5559
}, etcdPackage)
5660

@@ -65,7 +69,7 @@ func TestQuerierForDirectory(t *testing.T) {
6569

6670
etcdChannelEntries, err := store.GetChannelEntriesThatReplace(context.TODO(), "etcdoperator.v0.9.0")
6771
require.NoError(t, err)
68-
require.ElementsMatch(t, []*registry.ChannelEntry{{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}}, etcdChannelEntries)
72+
require.ElementsMatch(t, []*registry.ChannelEntry{{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"},{"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}, }, etcdChannelEntries)
6973

7074
etcdBundleByReplaces, err := store.GetBundleThatReplaces(context.TODO(), "etcdoperator.v0.9.0", "etcd", "alpha")
7175
require.NoError(t, err)
@@ -78,12 +82,17 @@ func TestQuerierForDirectory(t *testing.T) {
7882
{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.1"},
7983
{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"},
8084
{"etcd", "beta", "etcdoperator.v0.6.1", ""},
81-
{"etcd", "beta", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"}}, etcdChannelEntriesThatProvide)
85+
{"etcd", "beta", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"},
86+
{"etcd", "stable", "etcdoperator.v0.6.1", ""},
87+
{"etcd", "stable", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"},
88+
{"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.1"},
89+
{"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"},}, etcdChannelEntriesThatProvide)
8290

8391
etcdLatestChannelEntriesThatProvide, err := store.GetLatestChannelEntriesThatProvide(context.TODO(), "etcd.database.coreos.com", "v1beta2", "EtcdCluster")
8492
require.NoError(t, err)
8593
require.ElementsMatch(t, []*registry.ChannelEntry{{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"},
86-
{"etcd", "beta", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"}}, etcdLatestChannelEntriesThatProvide)
94+
{"etcd", "beta", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"},
95+
{"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}}, etcdLatestChannelEntriesThatProvide)
8796

8897
etcdBundleByProvides, entry, err := store.GetBundleThatProvides(context.TODO(), "etcd.database.coreos.com", "v1beta2", "EtcdCluster")
8998
require.NoError(t, err)

‎pkg/sqlite/query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (s *SQLQuerier) GetPackage(ctx context.Context, name string) (*registry.Pac
9494
},
9595
}
9696

97-
if rows.Next() {
97+
for rows.Next() {
9898
if err := rows.Scan(&pkgName, &defaultChannel, &channelName, &bundleName); err != nil {
9999
return nil, err
100100
}

0 commit comments

Comments
 (0)