-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lifubang <lifubang@acmcoder.com> code optimization Signed-off-by: Lifubang <lifubang@acmcoder.com> fixes no such exec error when tty resize Signed-off-by: Lifubang <lifubang@acmcoder.com>
- Loading branch information
Showing
3 changed files
with
96 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package container | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/docker/cli/cli/command" | ||
"github.com/docker/cli/internal/test" | ||
"github.com/docker/docker/api/types" | ||
"github.com/pkg/errors" | ||
"gotest.tools/assert" | ||
is "gotest.tools/assert/cmp" | ||
) | ||
|
||
func TestSafeResizeTtyErrors(t *testing.T) { | ||
expectedError := "Resize tty error, we'll use a default size. You can resize the tty size manually.\n" | ||
fakeContainerExecResizeFunc := func(id string, options types.ResizeOptions) error { | ||
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}) | ||
safeResizeTty(ctx, cli, "8mm8nn8tt8bb", true, fakeResizeTtyFunc) | ||
time.Sleep(100 * time.Millisecond) | ||
assert.Check(t, is.Equal(expectedError, cli.ErrBuffer().String())) | ||
} |