diff --git a/server/registry/actions_artifacts_test.go b/server/registry/actions_artifacts_test.go index 424f067e1..eaea79756 100644 --- a/server/registry/actions_artifacts_test.go +++ b/server/registry/actions_artifacts_test.go @@ -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", @@ -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", @@ -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) @@ -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", @@ -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", @@ -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) diff --git a/server/registry/internal/storage/list.go b/server/registry/internal/storage/list.go index 6f80ab932..ca6a5828b 100644 --- a/server/registry/internal/storage/list.go +++ b/server/registry/internal/storage/list.go @@ -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) @@ -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)