Skip to content

Commit

Permalink
Disable tests that list artifacts across projects in hosted mode, fix…
Browse files Browse the repository at this point in the history
… bugs in listing artifacts across apis. (#842)
  • Loading branch information
timburks authored Nov 16, 2022
1 parent c05ed76 commit fa370d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
26 changes: 18 additions & 8 deletions server/registry/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,9 +1567,10 @@ func TestSpecRevisionArtifacts(t *testing.T) {

t.Run("list artifacts across", func(t *testing.T) {
tests := []struct {
desc string
req *rpc.ListArtifactsRequest
want *rpc.ListArtifactsResponse
admin bool
desc string
req *rpc.ListArtifactsRequest
want *rpc.ListArtifactsResponse
}{
{
desc: "specified spec revision",
Expand Down Expand Up @@ -1662,7 +1663,8 @@ func TestSpecRevisionArtifacts(t *testing.T) {
},
},
{
desc: "all revisions in all projects",
admin: true,
desc: "all revisions in all projects",
req: &rpc.ListArtifactsRequest{
Parent: "projects/-/locations/global/apis/-/versions/-/specs/-@-",
OrderBy: "create_time",
Expand All @@ -1679,6 +1681,9 @@ func TestSpecRevisionArtifacts(t *testing.T) {

for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
if test.admin && adminServiceUnavailable() {
t.Skip(testRequiresAdminService)
}
got, err := server.ListArtifacts(ctx, test.req)
if err != nil {
t.Fatalf("ListArtifacts(%+v) returned error: %s", test.req, err)
Expand Down Expand Up @@ -1825,9 +1830,10 @@ func TestDeploymentRevisionArtifacts(t *testing.T) {

t.Run("list artifacts across", func(t *testing.T) {
tests := []struct {
desc string
req *rpc.ListArtifactsRequest
want *rpc.ListArtifactsResponse
admin bool
desc string
req *rpc.ListArtifactsRequest
want *rpc.ListArtifactsResponse
}{
{
desc: "specified deployment revision",
Expand Down Expand Up @@ -1906,7 +1912,8 @@ func TestDeploymentRevisionArtifacts(t *testing.T) {
},
},
{
desc: "all revisions in all projects",
admin: true,
desc: "all revisions in all projects",
req: &rpc.ListArtifactsRequest{
Parent: "projects/-/locations/global/apis/-/deployments/-@-",
OrderBy: "create_time",
Expand All @@ -1923,6 +1930,9 @@ func TestDeploymentRevisionArtifacts(t *testing.T) {

for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
if test.admin && adminServiceUnavailable() {
t.Skip(testRequiresAdminService)
}
got, err := server.ListArtifacts(ctx, test.req)
if err != nil {
t.Fatalf("ListArtifacts(%+v) returned error: %s", test.req, err)
Expand Down
4 changes: 2 additions & 2 deletions server/registry/internal/storage/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ func (c *Client) ListSpecRevisionArtifacts(ctx context.Context, parent names.Spe

op := c.db.WithContext(ctx)
if id := parent.ProjectID; id != "-" {
op.Where("artifacts.project_id = ?", id)
op = op.Where("artifacts.project_id = ?", id)
}
if id := parent.ApiID; id != "-" {
op = op.Where("artifacts.api_id = ?", id)
Expand Down Expand Up @@ -1211,7 +1211,7 @@ func (c *Client) ListDeploymentRevisionArtifacts(ctx context.Context, parent nam

op := c.db.WithContext(ctx)
if id := parent.ProjectID; id != "-" {
op.Where("artifacts.project_id = ?", id)
op = op.Where("artifacts.project_id = ?", id)
}
if id := parent.ApiID; id != "-" {
op = op.Where("artifacts.api_id = ?", id)
Expand Down

0 comments on commit fa370d3

Please sign in to comment.