diff options
author | Nicolas De Loof <nicolas.deloof@gmail.com> | 2019-08-28 13:46:32 +0200 |
---|---|---|
committer | Nicolas De Loof <nicolas.deloof@gmail.com> | 2022-05-12 11:36:31 +0200 |
commit | af5d83a6410f6a6bbe89f1a13d72b1982a3973cc (patch) | |
tree | b34ec548bd48a729864191765cc064301f96710f /integration | |
parent | 7c69b6dc08c7ce128c3015e08076641c2c5c40e5 (diff) | |
download | docker-af5d83a6410f6a6bbe89f1a13d72b1982a3973cc.tar.gz |
Make it explicit raw|multiplexed stream implementation being used
fix #35761
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Diffstat (limited to 'integration')
-rw-r--r-- | integration/container/attach_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/integration/container/attach_test.go b/integration/container/attach_test.go new file mode 100644 index 0000000000..bc7a659c72 --- /dev/null +++ b/integration/container/attach_test.go @@ -0,0 +1,50 @@ +package container // import "github.com/docker/docker/integration/container" + +import ( + "context" + "testing" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" + "gotest.tools/v3/assert" +) + +func TestAttachWithTTY(t *testing.T) { + testAttach(t, true, types.MediaTypeRawStream) +} + +func TestAttachWithoutTTy(t *testing.T) { + testAttach(t, false, types.MediaTypeMultiplexedStream) +} + +func testAttach(t *testing.T, tty bool, expected string) { + defer setupTest(t)() + client := testEnv.APIClient() + + resp, err := client.ContainerCreate(context.Background(), + &container.Config{ + Image: "busybox", + Cmd: []string{"echo", "hello"}, + Tty: tty, + }, + &container.HostConfig{}, + &network.NetworkingConfig{}, + nil, + "", + ) + assert.NilError(t, err) + container := resp.ID + defer client.ContainerRemove(context.Background(), container, types.ContainerRemoveOptions{ + Force: true, + }) + + attach, err := client.ContainerAttach(context.Background(), container, types.ContainerAttachOptions{ + Stdout: true, + Stderr: true, + }) + assert.NilError(t, err) + mediaType, ok := attach.MediaType() + assert.Check(t, ok) + assert.Check(t, mediaType == expected) +} |