Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions internal/provider/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,24 @@ func startSSHServer(ctx context.Context, t testing.TB) string {
t.Logf("command failed: %s", err)
return
}
t.Cleanup(func() {
_ = in.Close()
_ = out.Close()
_ = cmd.Process.Kill()
})

go func() {
_, _ = io.Copy(in, s)
_ = in.Close()
}()
outDone := make(chan struct{})
go func() {
defer close(outDone)
_, _ = io.Copy(s, out)
_ = out.Close()
_ = s.CloseWrite()
}()
t.Cleanup(func() {
_ = in.Close()
_ = out.Close()
<-outDone
_ = cmd.Process.Kill()
})
err = cmd.Wait()
if err != nil {
t.Logf("command failed: %s", err)
Expand All @@ -149,7 +152,7 @@ func startSSHServer(ctx context.Context, t testing.TB) string {

err = s.Exit(cmd.ProcessState.ExitCode())
if err != nil {
t.Logf("session exit failed: %s", err)
t.Errorf("session exit failed: %s", err)
}
},
}
Expand Down