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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-06-27 16:03:01 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-07-04 11:49:11 +0300
commit3b442616d63cdbf12cff2fb467708ba2d93e8534 (patch)
tree0420c7bb62f67e8dc0ecaa73dfd1fa3492b931d4
parent248f685e91e90225e4d95b62d6b039fb54bf8ab5 (diff)
repository: Fix CreateFork test behaviour with Praefect
Some of the tests for CreateFork assert whether Gitaly correctly validates invalid requests. One of these tests is intended to check for the case where the source repository wasn't provided. But because the repository has already been created at that point, Praefect has diverging behaviour from Gitaly as it will refuse to re-create the repository. Fix this by instead asking for a new repository to be created.
-rw-r--r--internal/gitaly/service/repository/create_fork_test.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go
index b57eaec9f..c45b68860 100644
--- a/internal/gitaly/service/repository/create_fork_test.go
+++ b/internal/gitaly/service/repository/create_fork_test.go
@@ -259,7 +259,6 @@ func TestCreateFork_validate(t *testing.T) {
ctx := testhelper.Context(t)
cfg, cli := setupRepositoryServiceWithoutRepo(t)
- repo, _ := gittest.CreateRepository(t, ctx, cfg)
srcRepo, _ := gittest.CreateRepository(t, ctx, cfg)
// Praefect does not rewrite the SourceRepository storage name, confirm
@@ -272,17 +271,23 @@ func TestCreateFork_validate(t *testing.T) {
expectedErr error
}{
{
- desc: "repository not provided",
- req: &gitalypb.CreateForkRequest{Repository: nil, SourceRepository: srcRepo},
+ desc: "repository not provided",
+ req: &gitalypb.CreateForkRequest{
+ Repository: nil,
+ SourceRepository: srcRepo,
+ },
expectedErr: structerr.NewInvalidArgument("%w", storage.ErrRepositoryNotSet),
},
{
desc: "source repository not provided",
- req: &gitalypb.CreateForkRequest{Repository: repo, SourceRepository: nil},
- expectedErr: testhelper.GitalyOrPraefect(
- structerr.NewInvalidArgument("validating source repository: %w", storage.ErrRepositoryNotSet),
- structerr.NewAlreadyExists("route repository creation: reserve repository id: repository already exists"),
- ),
+ req: &gitalypb.CreateForkRequest{
+ Repository: &gitalypb.Repository{
+ StorageName: cfg.Storages[0].Name,
+ RelativePath: gittest.NewRepositoryName(t),
+ },
+ SourceRepository: nil,
+ },
+ expectedErr: structerr.NewInvalidArgument("validating source repository: %w", storage.ErrRepositoryNotSet),
},
} {
t.Run(tc.desc, func(t *testing.T) {