(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestContainerWaitProxyInterruptLong(t *testing.T) { |
| 105 | ctx, cancel := context.WithCancel(t.Context()) |
| 106 | defer cancel() |
| 107 | |
| 108 | const expectedURL = "/containers/container_id/wait" |
| 109 | msg := strings.Repeat("x", containerWaitErrorMsgLimit*5) |
| 110 | client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) { |
| 111 | if err := assertRequest(req, http.MethodPost, expectedURL); err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | return mockResponse(http.StatusOK, nil, msg)(req) |
| 115 | })) |
| 116 | assert.NilError(t, err) |
| 117 | |
| 118 | wait := client.ContainerWait(ctx, "container_id", ContainerWaitOptions{}) |
| 119 | select { |
| 120 | case err := <-wait.Error: |
| 121 | // LimitReader limiting isn't exact, because of how the Readers do chunking. |
| 122 | assert.Check(t, len(err.Error()) <= containerWaitErrorMsgLimit*2, "Expected error to be limited around %d, actual length: %d", containerWaitErrorMsgLimit, len(err.Error())) |
| 123 | case result := <-wait.Result: |
| 124 | t.Errorf("Unexpected result: %v", result) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func TestContainerWaitErrorHandling(t *testing.T) { |
| 129 | for _, test := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…