diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-09 10:03:43 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-11 14:50:45 +0300 |
commit | f2724db8fa40e78f6fa0d8f3c4b6f0c91f6ad9a2 (patch) | |
tree | 4e08e6486ac55a36ce21d80589b4e817832d8734 | |
parent | 2fba7a1b2c962a535f1853dc301af2c859645f29 (diff) |
Replace MustRunCommand with Exec in ensureSplitIndexExists
Usages of the MustRunCommand replaced with Exec in order
to break dependency on the global config.Config variable.
The signature of the function changed to accept config.Cfg
parameter as now it is required by the implementation.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r-- | internal/gitaly/service/operations/squash_test.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go index 0894ac9b8..dce5c478c 100644 --- a/internal/gitaly/service/operations/squash_test.go +++ b/internal/gitaly/service/operations/squash_test.go @@ -14,6 +14,7 @@ import ( "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/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/helper/text" "gitlab.com/gitlab-org/gitaly/internal/testhelper" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" @@ -126,8 +127,8 @@ func TestUserSquash_stableID(t *testing.T) { }, commit) } -func ensureSplitIndexExists(t *testing.T, repoDir string) bool { - testhelper.MustRunCommand(t, nil, "git", "-C", repoDir, "update-index", "--add") +func ensureSplitIndexExists(t *testing.T, cfg config.Cfg, repoDir string) bool { + gittest.Exec(t, cfg, "-C", repoDir, "update-index", "--add") fis, err := ioutil.ReadDir(repoDir) require.NoError(t, err) @@ -190,9 +191,9 @@ func TestSplitIndex(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - ctx, _, repo, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) - require.False(t, ensureSplitIndexExists(t, repoPath)) + require.False(t, ensureSplitIndexExists(t, cfg, repoPath)) request := &gitalypb.UserSquashRequest{ Repository: repo, @@ -207,7 +208,7 @@ func TestSplitIndex(t *testing.T) { response, err := client.UserSquash(ctx, request) require.NoError(t, err) require.Empty(t, response.GetGitError()) - require.False(t, ensureSplitIndexExists(t, repoPath)) + require.False(t, ensureSplitIndexExists(t, cfg, repoPath)) } func TestSquashRequestWithRenamedFiles(t *testing.T) { |