diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-01-20 19:04:24 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-02-02 14:24:22 +0300 |
commit | a514eb9024d5b7b2583e44515a3dd2f706e72e26 (patch) | |
tree | 83d63603ed0cc361d79b85c960fc086bf173f4ac | |
parent | c1e9a464611d66763e2e071042030e3c3a473f80 (diff) |
Convert CreateFork test to create repository via API
This commits converst CreateFork_successful to create the repository
via API. The test has some custom server setup code so this was left
in a separate commit for clarity.
-rw-r--r-- | internal/gitaly/service/repository/create_fork_test.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go index 618f12d82..f5c080942 100644 --- a/internal/gitaly/service/repository/create_fork_test.go +++ b/internal/gitaly/service/repository/create_fork_test.go @@ -64,7 +64,7 @@ func TestCreateFork_successful(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { - cfg, repo, _ := testcfg.BuildWithRepo(t) + cfg := testcfg.Build(t) testcfg.BuildGitalyHooks(t, cfg) testcfg.BuildGitalySSH(t, cfg) @@ -74,15 +74,21 @@ func TestCreateFork_successful(t *testing.T) { conn *grpc.ClientConn ) + createRepoConfig := gittest.CreateRepositoryConfig{ + Seed: gittest.SeedGitLabTest, + } if tt.secure { cfg.TLS = tlsConfig cfg.TLSListenAddr = runSecureServer(t, cfg, nil) client, conn = newSecureRepoClient(t, cfg.TLSListenAddr, cfg.Auth.Token, certPool) - defer conn.Close() + t.Cleanup(func() { conn.Close() }) + createRepoConfig.ClientConn = conn } else { client, cfg.SocketPath = runRepositoryService(t, cfg, nil) } + repo, _ := gittest.CreateRepository(ctx, t, cfg, createRepoConfig) + ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) forkedRepo := &gitalypb.Repository{ @@ -122,7 +128,10 @@ func TestCreateFork_refs(t *testing.T) { testcfg.BuildGitalyHooks(t, cfg) testcfg.BuildGitalySSH(t, cfg) - sourceRepo, sourceRepoPath := gittest.InitRepo(t, cfg, cfg.Storages[0]) + client, socketPath := runRepositoryService(t, cfg, nil) + cfg.SocketPath = socketPath + + sourceRepo, sourceRepoPath := gittest.CreateRepository(ctx, t, cfg) // Prepare the source repository with a bunch of refs and a non-default HEAD ref so we can // assert that the target repo gets created with the correct set of refs. @@ -137,9 +146,6 @@ func TestCreateFork_refs(t *testing.T) { } gittest.Exec(t, cfg, "-C", sourceRepoPath, "symbolic-ref", "HEAD", "refs/heads/something") - client, socketPath := runRepositoryService(t, cfg, nil) - cfg.SocketPath = socketPath - ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg)) targetRepo := &gitalypb.Repository{ |