mirror of
https://github.com/coder/terraform-provider-envbuilder.git
synced 2025-07-27 05:47:50 +00:00
fix: prevent test flake by waiting on copy (#27)
This commit is contained in:
parent
a4e82b3d8c
commit
a2a5fcf79b
1 changed files with 4 additions and 2 deletions
|
@ -135,17 +135,19 @@ func startSSHServer(ctx context.Context, t testing.TB) string {
|
|||
_, _ = io.Copy(in, s)
|
||||
_ = in.Close()
|
||||
}()
|
||||
outCopyDone := make(chan struct{})
|
||||
go func() {
|
||||
_, _ = io.Copy(s, out)
|
||||
_ = out.Close()
|
||||
_ = s.CloseWrite()
|
||||
close(outCopyDone)
|
||||
}()
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
t.Logf("command failed: %s", err)
|
||||
}
|
||||
<-outCopyDone
|
||||
|
||||
t.Logf("session ended: %s", s.RawCommand())
|
||||
t.Logf("session ended (cmd=%q, code=%d)", s.RawCommand(), cmd.ProcessState.ExitCode())
|
||||
|
||||
err = s.Exit(cmd.ProcessState.ExitCode())
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue