(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestAttach(t *testing.T) { |
| 21 | ctx := setupTest(t) |
| 22 | apiClient := testEnv.APIClient() |
| 23 | |
| 24 | tests := []struct { |
| 25 | doc string |
| 26 | tty bool |
| 27 | expectedMediaType string |
| 28 | }{ |
| 29 | { |
| 30 | doc: "without TTY", |
| 31 | expectedMediaType: types.MediaTypeMultiplexedStream, |
| 32 | }, |
| 33 | { |
| 34 | doc: "with TTY", |
| 35 | tty: true, |
| 36 | expectedMediaType: types.MediaTypeRawStream, |
| 37 | }, |
| 38 | } |
| 39 | for _, tc := range tests { |
| 40 | t.Run(tc.doc, func(t *testing.T) { |
| 41 | t.Parallel() |
| 42 | |
| 43 | ctx := testutil.StartSpan(ctx, t) |
| 44 | resp, err := apiClient.ContainerCreate(ctx, client.ContainerCreateOptions{ |
| 45 | Config: &container.Config{ |
| 46 | Image: "busybox", |
| 47 | Cmd: []string{"echo", "hello"}, |
| 48 | Tty: tc.tty, |
| 49 | }, |
| 50 | HostConfig: &container.HostConfig{}, |
| 51 | NetworkingConfig: &network.NetworkingConfig{}, |
| 52 | }) |
| 53 | assert.NilError(t, err) |
| 54 | attach, err := apiClient.ContainerAttach(ctx, resp.ID, client.ContainerAttachOptions{ |
| 55 | Stdout: true, |
| 56 | Stderr: true, |
| 57 | }) |
| 58 | assert.NilError(t, err) |
| 59 | mediaType, ok := attach.MediaType() |
| 60 | assert.Check(t, ok) |
| 61 | assert.Check(t, is.Equal(mediaType, tc.expectedMediaType)) |
| 62 | }) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | // Regression test for #37182 |
| 67 | func TestAttachDisconnectLeak(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…