diff options
author | Toon Claes <toon@gitlab.com> | 2022-04-04 14:34:29 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2022-04-04 14:34:29 +0300 |
commit | cc452e83e51c9c8d8e34a04b5673d6533d1a3b04 (patch) | |
tree | 8b9d87ffbfb32fcf351b50fa95a48d16d6a1c134 | |
parent | fc158823aa4e499001354081435ca2bad3ab8aca (diff) |
ssh: Split out the push command in test
In a future commit we'd like to process the stdout and stderr output
from the ssh push command separately. With this commit the setting up of
the command is extracted into a function so in the future it's possible
to specify where to write stdout/stderr to.
-rw-r--r-- | internal/gitaly/service/ssh/receive_pack_test.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go index a810d6766..6d5fb606f 100644 --- a/internal/gitaly/service/ssh/receive_pack_test.go +++ b/internal/gitaly/service/ssh/receive_pack_test.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "os/exec" "path/filepath" "strings" "testing" @@ -599,7 +600,7 @@ func setupSSHClone(t *testing.T, cfg config.Cfg, remoteRepo *gitalypb.Repository } } -func sshPush(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) (string, string, error) { +func sshPushCommand(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) *exec.Cmd { pbTempRepo := &gitalypb.Repository{ StorageName: params.storageName, RelativePath: cloneDetails.TempRepo, @@ -624,6 +625,12 @@ func sshPush(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSH fmt.Sprintf("GIT_SSH_COMMAND=%s receive-pack", filepath.Join(cfg.BinDir, "gitaly-ssh")), } + return cmd +} + +func sshPush(ctx context.Context, t *testing.T, cfg config.Cfg, cloneDetails SSHCloneDetails, serverSocketPath string, params pushParams) (string, string, error) { + cmd := sshPushCommand(ctx, t, cfg, cloneDetails, serverSocketPath, params) + out, err := cmd.CombinedOutput() if err != nil { return "", "", fmt.Errorf("error pushing: %v: %q", err, out) |