MCPcopy
hub / github.com/moby/moby / TestContainerWaitProxyInterruptLong

Function TestContainerWaitProxyInterruptLong

client/container_wait_test.go:104–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func 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
128func TestContainerWaitErrorHandling(t *testing.T) {
129 for _, test := range []struct {

Callers

nothing calls this directly

Calls 9

WithMockClientFunction · 0.85
assertRequestFunction · 0.85
mockResponseFunction · 0.85
CheckMethod · 0.80
ErrorfMethod · 0.80
NewFunction · 0.70
ContextMethod · 0.65
ContainerWaitMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…