-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1867848: Return empty properties and dependencies in ListBundles responses. #417
Bug 1867848: Return empty properties and dependencies in ListBundles responses. #417
Conversation
@benluddy: This pull request references Bugzilla bug 1867848, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
list = append(list, entry) | ||
} | ||
} | ||
return list | ||
} | ||
|
||
func uniqueProps(props []*api.Property) []*api.Property { | ||
keys := make(map[string]bool) | ||
list := []*api.Property{} | ||
keys := make(map[string]struct{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pkg/sqlite/query_test.go
Outdated
) | ||
|
||
func TestListBundles(t *testing.T) { | ||
const query = `SELECT DISTINCT channel_entry.entry_id, operatorbundle.bundle, operatorbundle.bundlepath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I misreading something or is this const just not used? Is it injected into something somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, good catch. The ListBundles impl calls out to other methods on SQLQuerier, which in turn make other database queries, so I was originally going to set the stub behavior based on the query arg. I ended up stubbing based on invocation count instead and didn't use it.
Bundles that don't have any properties/dependencies should return nil or [] for those fields, but due to an error in handling NULL column values, a single zero-valued entry was being returned.
5601835
to
00b48a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Thanks for doing this, I definitely prefer DI-ing a mock data source over working w/ database files on-disk.
I'm also wondering if there's a generic ORM package (codegen?) we could use. Food for thought.
@@ -1,3 +1,5 @@ | |||
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -o sqlitefakes/fake_rowscanner.go . RowScanner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
bundlesMap := map[string]*api.Bundle{} | ||
for rows.Next() { | ||
var entryID sql.NullInt64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
"github.com/operator-framework/operator-registry/pkg/api" | ||
"github.com/operator-framework/operator-registry/pkg/sqlite" | ||
"github.com/operator-framework/operator-registry/pkg/sqlite/sqlitefakes" | ||
"github.com/stretchr/testify/assert" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import order
} | ||
|
||
func unique(deps []*api.Dependency) []*api.Dependency { | ||
keys := make(map[string]bool) | ||
list := []*api.Dependency{} | ||
keys := make(map[string]struct{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: benluddy, njhale The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@benluddy: All pull requests linked via external trackers have merged: operator-framework/operator-registry#417. Bugzilla bug 1867848 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Bundles that don't have any properties/dependencies should return nil
or [] for those fields, but due to an error in handling NULL column
values, a single zero-valued entry was being returned.