diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-04-06 12:17:56 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-04-06 12:17:56 +0300 |
commit | 82a9ba26220bf30d891fc29cca2d4c517f39e024 (patch) | |
tree | 81a322af7a6a95847d6b8f70f30be6e090dde22d | |
parent | da585c27e6e5e6a69d42c81ae3954b761329e322 (diff) | |
parent | cbb2c8737cccc279d7e77d1b6978357fe1c2ace8 (diff) |
Merge branch 'ps-rm-config-gitaly-git2go' into 'master'
Remove config.Config from gitaly-git2go package
See merge request gitlab-org/gitaly!3331
-rw-r--r-- | cmd/gitaly-git2go/cherry_pick_test.go | 15 | ||||
-rw-r--r-- | cmd/gitaly-git2go/conflicts/conflicts_test.go | 11 | ||||
-rw-r--r-- | cmd/gitaly-git2go/main_test.go | 2 | ||||
-rw-r--r-- | cmd/gitaly-git2go/merge_test.go | 27 | ||||
-rw-r--r-- | cmd/gitaly-git2go/revert_test.go | 15 | ||||
-rw-r--r-- | cmd/gitaly-git2go/submodule_test.go | 15 |
6 files changed, 42 insertions, 43 deletions
diff --git a/cmd/gitaly-git2go/cherry_pick_test.go b/cmd/gitaly-git2go/cherry_pick_test.go index a7c0459ec..49695c749 100644 --- a/cmd/gitaly-git2go/cherry_pick_test.go +++ b/cmd/gitaly-git2go/cherry_pick_test.go @@ -11,15 +11,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" cmdtesthelper "gitlab.com/gitlab-org/gitaly/cmd/gitaly-git2go/testhelper" - "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/git2go" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" ) func TestCherryPick_validation(t *testing.T) { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) testcases := []struct { desc string @@ -71,7 +70,7 @@ func TestCherryPick_validation(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - _, err := tc.request.Run(ctx, config.Config) + _, err := tc.request.Run(ctx, cfg) require.EqualError(t, err, tc.expectedErr) }) } @@ -145,8 +144,8 @@ func TestCherryPick(t *testing.T) { }, } for _, tc := range testcases { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) base := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{nil}, tc.base) @@ -176,7 +175,7 @@ func TestCherryPick(t *testing.T) { Message: "Foo", Ours: ours, Commit: commit, - }.Run(ctx, config.Config) + }.Run(ctx, cfg) if tc.expectedErrMsg != "" { require.EqualError(t, err, tc.expectedErrMsg) diff --git a/cmd/gitaly-git2go/conflicts/conflicts_test.go b/cmd/gitaly-git2go/conflicts/conflicts_test.go index 7f9d483c8..b67c06612 100644 --- a/cmd/gitaly-git2go/conflicts/conflicts_test.go +++ b/cmd/gitaly-git2go/conflicts/conflicts_test.go @@ -9,10 +9,9 @@ import ( git "github.com/libgit2/git2go/v31" "github.com/stretchr/testify/require" cmdtesthelper "gitlab.com/gitlab-org/gitaly/cmd/gitaly-git2go/testhelper" - "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/git2go" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" ) func TestMain(m *testing.M) { @@ -23,7 +22,6 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) return m.Run() } @@ -178,8 +176,9 @@ func TestConflicts(t *testing.T) { } for _, tc := range testcases { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + + testhelper.ConfigureGitalyGit2GoBin(t, cfg) base := cmdtesthelper.BuildCommit(t, repoPath, nil, tc.base) ours := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{base}, tc.ours) @@ -193,7 +192,7 @@ func TestConflicts(t *testing.T) { Repository: repoPath, Ours: ours.String(), Theirs: theirs.String(), - }.Run(ctx, config.Config) + }.Run(ctx, cfg) require.NoError(t, err) require.Equal(t, tc.conflicts, response.Conflicts) diff --git a/cmd/gitaly-git2go/main_test.go b/cmd/gitaly-git2go/main_test.go index 1202aedf9..e1003ac85 100644 --- a/cmd/gitaly-git2go/main_test.go +++ b/cmd/gitaly-git2go/main_test.go @@ -6,7 +6,6 @@ import ( "os" "testing" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -18,6 +17,5 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) return m.Run() } diff --git a/cmd/gitaly-git2go/merge_test.go b/cmd/gitaly-git2go/merge_test.go index a05412464..efa767498 100644 --- a/cmd/gitaly-git2go/merge_test.go +++ b/cmd/gitaly-git2go/merge_test.go @@ -13,13 +13,12 @@ import ( cmdtesthelper "gitlab.com/gitlab-org/gitaly/cmd/gitaly-git2go/testhelper" "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/git2go" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" ) func TestMergeFailsWithMissingArguments(t *testing.T) { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) testcases := []struct { desc string @@ -67,7 +66,7 @@ func TestMergeFailsWithMissingArguments(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - _, err := tc.request.Run(ctx, config.Config) + _, err := tc.request.Run(ctx, cfg) require.Error(t, err) require.Equal(t, tc.expectedErr, err.Error()) }) @@ -75,12 +74,15 @@ func TestMergeFailsWithMissingArguments(t *testing.T) { } func TestMergeFailsWithInvalidRepositoryPath(t *testing.T) { + cfg := testcfg.Build(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) + ctx, cancel := testhelper.Context() defer cancel() _, err := git2go.MergeCommand{ Repository: "/does/not/exist", AuthorName: "Foo", AuthorMail: "foo@example.com", Message: "Foo", Ours: "HEAD", Theirs: "HEAD", - }.Run(ctx, config.Config) + }.Run(ctx, cfg) require.Error(t, err) require.Contains(t, err.Error(), "merge: could not open repository") } @@ -173,8 +175,8 @@ func TestMergeTrees(t *testing.T) { } for _, tc := range testcases { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) base := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{nil}, tc.base) ours := cmdtesthelper.BuildCommit(t, repoPath, []*git.Oid{base}, tc.ours) @@ -194,7 +196,7 @@ func TestMergeTrees(t *testing.T) { Message: "Merge message", Ours: ours.String(), Theirs: theirs.String(), - }.Run(ctx, config.Config) + }.Run(ctx, cfg) if tc.expectedStderr != "" { require.Error(t, err) @@ -232,7 +234,10 @@ func TestMergeTrees(t *testing.T) { } func TestMerge_recursive(t *testing.T) { - _, repoPath, cleanup := gittest.InitBareRepo(t) + cfg := testcfg.Build(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) + + _, repoPath, cleanup := gittest.InitBareRepoAt(t, cfg.Storages[0]) defer cleanup() base := cmdtesthelper.BuildCommit(t, repoPath, nil, map[string]string{"base": "base\n"}) @@ -297,7 +302,7 @@ func TestMerge_recursive(t *testing.T) { Message: "Merge message", Ours: ours[len(ours)-1].String(), Theirs: theirs[len(theirs)-1].String(), - }.Run(ctx, config.Config) + }.Run(ctx, cfg) require.Error(t, err) require.Equal(t, err.Error(), "merge: could not auto-merge due to conflicts\n") @@ -312,7 +317,7 @@ func TestMerge_recursive(t *testing.T) { Message: "Merge message", Ours: ours[git2go.MergeRecursionLimit/2].String(), Theirs: theirs[git2go.MergeRecursionLimit/2].String(), - }.Run(ctx, config.Config) + }.Run(ctx, cfg) require.NoError(t, err) repo, err := git.OpenRepository(repoPath) diff --git a/cmd/gitaly-git2go/revert_test.go b/cmd/gitaly-git2go/revert_test.go index b24d5785c..8b63a841d 100644 --- a/cmd/gitaly-git2go/revert_test.go +++ b/cmd/gitaly-git2go/revert_test.go @@ -11,15 +11,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" cmdtesthelper "gitlab.com/gitlab-org/gitaly/cmd/gitaly-git2go/testhelper" - "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/git2go" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" ) func TestRevert_validation(t *testing.T) { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) testcases := []struct { desc string @@ -66,7 +65,7 @@ func TestRevert_validation(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - _, err := tc.request.Run(ctx, config.Config) + _, err := tc.request.Run(ctx, cfg) require.Error(t, err) require.EqualError(t, err, tc.expectedErr) }) @@ -151,8 +150,8 @@ func TestRevert_trees(t *testing.T) { } for _, tc := range testcases { t.Run(tc.desc, func(t *testing.T) { - _, repoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() + cfg, _, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) ours, revert := tc.setupRepo(t, repoPath) @@ -171,7 +170,7 @@ func TestRevert_trees(t *testing.T) { Revert: revert, } - response, err := request.Run(ctx, config.Config) + response, err := request.Run(ctx, cfg) if tc.expectedErr != "" { require.EqualError(t, err, tc.expectedErr) diff --git a/cmd/gitaly-git2go/submodule_test.go b/cmd/gitaly-git2go/submodule_test.go index f242aaf41..48a8bf8e2 100644 --- a/cmd/gitaly-git2go/submodule_test.go +++ b/cmd/gitaly-git2go/submodule_test.go @@ -9,12 +9,11 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitaly/internal/git" - "gitlab.com/gitlab-org/gitaly/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/internal/git/lstree" "gitlab.com/gitlab-org/gitaly/internal/git2go" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" + "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg" ) func TestSubmodule(t *testing.T) { @@ -87,16 +86,16 @@ func TestSubmodule(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - testRepo, testRepoPath, cleanup := gittest.CloneRepo(t) - defer cleanup() - repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config) + cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) + testhelper.ConfigureGitalyGit2GoBin(t, cfg) + repo := localrepo.New(git.NewExecCommandFactory(cfg), repoProto, cfg) - tc.command.Repository = testRepoPath + tc.command.Repository = repoPath ctx, cancel := testhelper.Context() defer cancel() - response, err := tc.command.Run(ctx, config.Config) + response, err := tc.command.Run(ctx, cfg) if tc.expectedStderr != "" { require.Error(t, err) require.Contains(t, err.Error(), tc.expectedStderr) @@ -115,7 +114,7 @@ func TestSubmodule(t *testing.T) { nil, "git", "-C", - testRepoPath, + repoPath, "ls-tree", "-z", fmt.Sprintf("%s^{tree}:", response.CommitID), |