MCPcopy
hub / github.com/gofiber/fiber / Test_FiberHandler_ClosesBodyStream

Function Test_FiberHandler_ClosesBodyStream

middleware/adaptor/adaptor_test.go:1084–1103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1082}
1083
1084func Test_FiberHandler_ClosesBodyStream(t *testing.T) {
1085 t.Parallel()
1086
1087 closed := &atomic.Bool{}
1088 body := &closeTrackingReader{
1089 ReadCloser: io.NopCloser(strings.NewReader("streamed body")),
1090 closed: closed,
1091 }
1092
1093 fiberH := func(c fiber.Ctx) error {
1094 return c.SendStream(body)
1095 }
1096 handlerFunc := FiberHandlerFunc(fiberH)
1097
1098 r := httptest.NewRequest(http.MethodGet, "/test", http.NoBody)
1099 w := httptest.NewRecorder()
1100
1101 handlerFunc.ServeHTTP(w, r)
1102 require.True(t, closed.Load())
1103}
1104
1105func Test_FiberHandler_ClosesBodyStreamOnWriteError(t *testing.T) {
1106 t.Parallel()

Callers

nothing calls this directly

Calls 4

FiberHandlerFuncFunction · 0.85
SendStreamMethod · 0.65
LoadMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected