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:
authorPavlo Strokov <pstrokov@gitlab.com>2021-05-08 11:08:39 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-05-11 14:25:16 +0300
commitb768a7fd8416ce9261147b7a516f8cf21c037342 (patch)
tree27a9bbe2600d6c0dd6baa4dac3784601619be4eb
parent2b825430d269b31fa2ec540313c35389692171ee (diff)
Replace MustRunCommand with gittest.Exec for getRefnames
To break dependency on the global config.Config variable the git commands should be executed with gittest.Exec. The function requires a config.Cfg to be passed as incoming parameter to use proper git binary for the command execution. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 7f85e1286..f0ac0951b 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -661,8 +661,8 @@ func remoteHTTPServer(t *testing.T, repoName, httpToken string) (*httptest.Serve
return s, fmt.Sprintf("%s/%s.git", s.URL, repoName)
}
-func getRefnames(t *testing.T, repoPath string) []string {
- result := testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "for-each-ref", "--format", "%(refname:lstrip=2)")
+func getRefnames(t *testing.T, cfg config.Cfg, repoPath string) []string {
+ result := gittest.Exec(t, cfg, "-C", repoPath, "for-each-ref", "--format", "%(refname:lstrip=2)")
return strings.Split(text.ChompBytes(result), "\n")
}
@@ -708,13 +708,13 @@ func testFetchRemoteOverHTTP(t *testing.T, cfg config.Cfg, rubySrv *rubyserver.S
req.RemoteParams.Url = s.URL + tc.remoteURL
}
- refs := getRefnames(t, forkedRepoPath)
+ refs := getRefnames(t, cfg, forkedRepoPath)
require.True(t, len(refs) > 1, "the advertisement.txt should have deleted all refs except for master")
_, err := client.FetchRemote(ctx, req)
require.NoError(t, err)
- refs = getRefnames(t, forkedRepoPath)
+ refs = getRefnames(t, cfg, forkedRepoPath)
require.Len(t, refs, 1)
assert.Equal(t, "master", refs[0])