Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2022-01-20 21:52:21 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2022-02-23 11:47:18 +0300
commit090f5dbc5c6bd8a889b076f35ab9bfbfd8a426f8 (patch)
tree51068efe13e6a55d48a9e63a32e1679074a6fd34
parentb3dc1f08990868af465b63b54199545850114758 (diff)
repository: Extend test coverage for WriteCommitGraph RPC
If repository is not provided the RPC returns specific error about it. Make sure NotFound code and specific message is returned in case requested repository doesn't exist on the disk.
-rw-r--r--internal/gitaly/service/repository/commit_graph.go5
-rw-r--r--internal/gitaly/service/repository/commit_graph_test.go9
2 files changed, 12 insertions, 2 deletions
diff --git a/internal/gitaly/service/repository/commit_graph.go b/internal/gitaly/service/repository/commit_graph.go
index b329bc099..c5db82700 100644
--- a/internal/gitaly/service/repository/commit_graph.go
+++ b/internal/gitaly/service/repository/commit_graph.go
@@ -3,6 +3,7 @@ package repository
import (
"context"
+ gitalyerrors "gitlab.com/gitlab-org/gitaly/v14/internal/errors"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -13,6 +14,10 @@ func (s *server) WriteCommitGraph(
ctx context.Context,
in *gitalypb.WriteCommitGraphRequest,
) (*gitalypb.WriteCommitGraphResponse, error) {
+ if in.GetRepository() == nil {
+ return nil, helper.ErrInvalidArgument(gitalyerrors.ErrEmptyRepository)
+ }
+
repo := s.localrepo(in.GetRepository())
if in.GetSplitStrategy() != gitalypb.WriteCommitGraphRequest_SizeMultiple {
diff --git a/internal/gitaly/service/repository/commit_graph_test.go b/internal/gitaly/service/repository/commit_graph_test.go
index 7f1bc7a9d..c55c64665 100644
--- a/internal/gitaly/service/repository/commit_graph_test.go
+++ b/internal/gitaly/service/repository/commit_graph_test.go
@@ -119,7 +119,7 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(ctx, t, testserver.WithDisablePraefect())
+ cfg, repo, _, client := setupRepositoryService(ctx, t, testserver.WithDisablePraefect())
for _, tc := range []struct {
desc string
@@ -137,13 +137,18 @@ func TestWriteCommitGraph_validationChecks(t *testing.T) {
{
desc: "no repository",
req: &gitalypb.WriteCommitGraphRequest{},
- expErr: status.Error(codes.InvalidArgument, `GetStorageByName: no such storage: ""`),
+ expErr: status.Error(codes.InvalidArgument, "empty Repository"),
},
{
desc: "invalid storage",
req: &gitalypb.WriteCommitGraphRequest{Repository: &gitalypb.Repository{StorageName: "invalid"}},
expErr: status.Error(codes.InvalidArgument, `GetStorageByName: no such storage: "invalid"`),
},
+ {
+ desc: "not existing repository",
+ req: &gitalypb.WriteCommitGraphRequest{Repository: &gitalypb.Repository{StorageName: repo.StorageName, RelativePath: "invalid"}},
+ expErr: status.Error(codes.NotFound, fmt.Sprintf(`GetRepoPath: not a git repository: "%s/invalid"`, cfg.Storages[0].Path)),
+ },
} {
t.Run(tc.desc, func(t *testing.T) {
//nolint:staticcheck