2018-11-21 08:41:51 -05:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/docker/cli/internal/test"
|
2023-10-13 14:34:32 -04:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2018-11-21 08:41:51 -05:00
|
|
|
"github.com/pkg/errors"
|
2020-02-22 12:12:14 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2018-11-21 08:41:51 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInitTtySizeErrors(t *testing.T) {
|
|
|
|
expectedError := "failed to resize tty, using default size\n"
|
2023-10-13 14:34:32 -04:00
|
|
|
fakeContainerExecResizeFunc := func(id string, options container.ResizeOptions) error {
|
2018-11-21 08:41:51 -05:00
|
|
|
return errors.Errorf("Error response from daemon: no such exec")
|
|
|
|
}
|
|
|
|
fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error {
|
|
|
|
height, width := uint(1024), uint(768)
|
|
|
|
return resizeTtyTo(ctx, cli.Client(), id, height, width, isExec)
|
|
|
|
}
|
|
|
|
ctx := context.Background()
|
|
|
|
cli := test.NewFakeCli(&fakeClient{containerExecResizeFunc: fakeContainerExecResizeFunc})
|
|
|
|
initTtySize(ctx, cli, "8mm8nn8tt8bb", true, fakeResizeTtyFunc)
|
2022-05-02 11:01:01 -04:00
|
|
|
time.Sleep(1500 * time.Millisecond)
|
2018-11-21 08:41:51 -05:00
|
|
|
assert.Check(t, is.Equal(expectedError, cli.ErrBuffer().String()))
|
|
|
|
}
|