diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-17 12:37:46 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-21 08:32:56 +0300 |
commit | 58ef2be67915e8afdaa6d79b99ab69f5413e51fe (patch) | |
tree | 91069dc8ded0ea7c7a285d1867e9e0a8c4e456ae /cmd/gitaly-ssh | |
parent | d19c6eab3ecc995ee5b947134657ebd92e35deb8 (diff) |
tests: Convert tests to use Git exec helper
Convert tests which spawn Git commands to use the Git execution helpers
as exposed by the gittest package. Running Git directly without the use
of either those helpers or the Git command factory is not supported
anymore.
Diffstat (limited to 'cmd/gitaly-ssh')
-rw-r--r-- | cmd/gitaly-ssh/auth_test.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go index 3dd82bea1..94b602f88 100644 --- a/cmd/gitaly-ssh/auth_test.go +++ b/cmd/gitaly-ssh/auth_test.go @@ -4,7 +4,6 @@ import ( "fmt" "net" "os" - "os/exec" "path/filepath" "strconv" "strings" @@ -15,6 +14,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/backchannel" "gitlab.com/gitlab-org/gitaly/v14/internal/cache" "gitlab.com/gitlab-org/gitaly/v14/internal/git" + "gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/server" @@ -120,9 +120,7 @@ func TestConnectivity(t *testing.T) { t.Run(testcase.name, func(t *testing.T) { addr, certFile := testcase.addr(t, cfg) - cmd := exec.Command(cfg.Git.BinPath, "ls-remote", "git@localhost:test/test.git", "refs/heads/master") - cmd.Stderr = os.Stderr - cmd.Env = []string{ + env := []string{ fmt.Sprintf("GITALY_PAYLOAD=%s", payload), fmt.Sprintf("GITALY_ADDRESS=%s", addr), fmt.Sprintf("GITALY_WD=%s", cwd), @@ -130,17 +128,16 @@ func TestConnectivity(t *testing.T) { fmt.Sprintf("GIT_SSH_COMMAND=%s upload-pack", filepath.Join(cfg.BinDir, "gitaly-ssh")), fmt.Sprintf("SSL_CERT_FILE=%s", certFile), } - if testcase.proxy { - cmd.Env = append(cmd.Env, + env = append(env, "http_proxy=http://invalid:1234", "https_proxy=https://invalid:1234", ) } - output, err := cmd.Output() - - require.NoError(t, err, "git ls-remote exit status") + output := gittest.ExecOpts(t, cfg, gittest.ExecConfig{ + Env: env, + }, "ls-remote", "git@localhost:test/test.git", "refs/heads/master") require.True(t, strings.HasSuffix(strings.TrimSpace(string(output)), "refs/heads/master")) }) } |