diff options
author | Karthik Nayak <knayak@gitlab.com> | 2023-06-14 12:39:12 +0300 |
---|---|---|
committer | Karthik Nayak <knayak@gitlab.com> | 2023-06-16 13:31:28 +0300 |
commit | ec67f0aed83fbbceaa5b0d75c6b7395140342f72 (patch) | |
tree | 0c9eb9851a350b52bf1e1bc5d3d2cd408d6be037 | |
parent | 66d72afe9830a17981e9cf703c3dd773a64fe586 (diff) |
conflicts: Remove unused function `setupConflictsService`
The `setupConflictsService` function is used to initialize the conflicts
service client with a seeded repository. In the previous commit, we got
rid of the last usage of this function. Now we can delete the function
and rename `setupConflictsServiceWithoutRepo` to
`setupConflictsService`.
3 files changed, 37 insertions, 49 deletions
diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go index adc2c932a..e0921cc72 100644 --- a/internal/gitaly/service/conflicts/list_conflict_files_test.go +++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go @@ -45,7 +45,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "Lists the expected conflict files", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -92,7 +92,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "Lists the expected conflict files with short OIDs", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -139,7 +139,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "conflict in submodules commits are not handled", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) _, subRepoPath := gittest.CreateRepository(tb, ctx, cfg) @@ -192,7 +192,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "Lists the expected conflict files with ancestor path", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) commonCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -249,7 +249,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "Lists the expected conflict files with huge diff", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -302,7 +302,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "invalid commit id on 'our' side", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) theirCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -326,7 +326,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "invalid commit id on 'their' side", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -350,7 +350,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "conflict side missing", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) commonCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -384,7 +384,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "allow tree conflicts", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) commonCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -446,7 +446,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "encoding error", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -472,7 +472,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "empty repo", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) _, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -501,7 +501,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "empty OurCommitId field", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) theirCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -524,7 +524,7 @@ func testListConflictFiles(t *testing.T, ctx context.Context) { { "empty TheirCommitId field", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go index d8dc63fe4..d501ca540 100644 --- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go +++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go @@ -55,7 +55,7 @@ func TestResolveConflicts(t *testing.T) { { "single file conflict, pick ours", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) baseCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -114,7 +114,7 @@ func TestResolveConflicts(t *testing.T) { { "single file conflict, pick theirs", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) baseCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -173,7 +173,7 @@ func TestResolveConflicts(t *testing.T) { { "single file conflict without ancestor, pick ours", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -228,7 +228,7 @@ func TestResolveConflicts(t *testing.T) { { "single file multi conflict", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) baseCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -294,7 +294,7 @@ func TestResolveConflicts(t *testing.T) { { "multi file multi conflict", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) baseCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( @@ -369,7 +369,7 @@ func TestResolveConflicts(t *testing.T) { { "single file conflict, remote repo", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) testcfg.BuildGitalySSH(t, cfg) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) @@ -427,7 +427,7 @@ func TestResolveConflicts(t *testing.T) { { "single file with only newline", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -473,7 +473,7 @@ func TestResolveConflicts(t *testing.T) { { "conflicting newline with embedded character", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -527,7 +527,7 @@ func TestResolveConflicts(t *testing.T) { { "conflicting carriage-return newlines", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -581,7 +581,7 @@ func TestResolveConflicts(t *testing.T) { { "conflict with no trailing newline", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -635,7 +635,7 @@ func TestResolveConflicts(t *testing.T) { { "conflict with existing conflict markers", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -685,7 +685,7 @@ func TestResolveConflicts(t *testing.T) { { "invalid OID", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -727,7 +727,7 @@ func TestResolveConflicts(t *testing.T) { { "resolved content is same as the conflict", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -775,7 +775,7 @@ func TestResolveConflicts(t *testing.T) { { "missing resolution for section", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithBranch("ours"), @@ -827,7 +827,7 @@ func TestResolveConflicts(t *testing.T) { { "empty User", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -855,7 +855,7 @@ func TestResolveConflicts(t *testing.T) { { "empty Repository", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -886,7 +886,7 @@ func TestResolveConflicts(t *testing.T) { { "empty TargetRepository", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -914,7 +914,7 @@ func TestResolveConflicts(t *testing.T) { { "empty OurCommitID", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -942,7 +942,7 @@ func TestResolveConflicts(t *testing.T) { { "empty TheirCommitID", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -970,7 +970,7 @@ func TestResolveConflicts(t *testing.T) { { "empty CommitMessage", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -998,7 +998,7 @@ func TestResolveConflicts(t *testing.T) { { "empty SourceBranch", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -1026,7 +1026,7 @@ func TestResolveConflicts(t *testing.T) { { "empty TargetBranch", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) return setupData{ @@ -1054,7 +1054,7 @@ func TestResolveConflicts(t *testing.T) { { "uses quarantine repo", func(tb testing.TB, ctx context.Context) setupData { - cfg, client := setupConflictsServiceWithoutRepo(tb, nil) + cfg, client := setupConflictsService(tb, nil) repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) testcfg.BuildGitalySSH(t, cfg) diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index 848a4b132..25e3658f8 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -3,10 +3,8 @@ package conflicts import ( - "context" "testing" - "gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/service" @@ -26,7 +24,7 @@ func TestMain(m *testing.M) { testhelper.Run(m) } -func setupConflictsServiceWithoutRepo(tb testing.TB, hookManager hook.Manager) (config.Cfg, gitalypb.ConflictsServiceClient) { +func setupConflictsService(tb testing.TB, hookManager hook.Manager) (config.Cfg, gitalypb.ConflictsServiceClient) { cfg := testcfg.Build(tb) testcfg.BuildGitalyGit2Go(tb, cfg) @@ -40,16 +38,6 @@ func setupConflictsServiceWithoutRepo(tb testing.TB, hookManager hook.Manager) ( return cfg, client } -func setupConflictsService(tb testing.TB, ctx context.Context, hookManager hook.Manager) (config.Cfg, *gitalypb.Repository, string, gitalypb.ConflictsServiceClient) { - cfg, client := setupConflictsServiceWithoutRepo(tb, hookManager) - - repo, repoPath := gittest.CreateRepository(tb, ctx, cfg, gittest.CreateRepositoryConfig{ - Seed: gittest.SeedGitLabTest, - }) - - return cfg, repo, repoPath, client -} - func runConflictsServer(tb testing.TB, cfg config.Cfg, hookManager hook.Manager) string { return testserver.RunGitalyServer(tb, cfg, func(srv *grpc.Server, deps *service.Dependencies) { gitalypb.RegisterConflictsServiceServer(srv, NewServer( |