attach: wait for exit code from ContainerWait

Such as with `docker run`, if a user CTRL-Cs while attached to a
container, we should forward the signal and wait for the exit from
`ContainerWait`, instead of just returning.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm
2024-07-25 09:27:45 +01:00
parent 788e99620d
commit 7b46bfc5ac
3 changed files with 19 additions and 17 deletions

View File

@ -1,7 +1,6 @@
package container
import (
"context"
"io"
"testing"
@ -86,11 +85,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
}
func TestGetExitStatus(t *testing.T) {
var (
expectedErr = errors.New("unexpected error")
errC = make(chan error, 1)
resultC = make(chan container.WaitResponse, 1)
)
expectedErr := errors.New("unexpected error")
testcases := []struct {
result *container.WaitResponse
@ -118,20 +113,20 @@ func TestGetExitStatus(t *testing.T) {
},
expectedError: cli.StatusError{StatusCode: 15},
},
{
err: context.Canceled,
expectedError: nil,
},
}
for _, testcase := range testcases {
errC := make(chan error, 1)
resultC := make(chan container.WaitResponse, 1)
if testcase.err != nil {
errC <- testcase.err
}
if testcase.result != nil {
resultC <- *testcase.result
}
err := getExitStatus(errC, resultC)
if testcase.expectedError == nil {
assert.NilError(t, err)
} else {