diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-08 11:08:39 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-11 14:25:16 +0300 |
commit | b768a7fd8416ce9261147b7a516f8cf21c037342 (patch) | |
tree | 27a9bbe2600d6c0dd6baa4dac3784601619be4eb | |
parent | 2b825430d269b31fa2ec540313c35389692171ee (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.go | 8 |
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]) |