(t *testing.T)
| 1052 | } |
| 1053 | |
| 1054 | func Test_FiberHandler_WithSendStreamWriter(t *testing.T) { |
| 1055 | t.Parallel() |
| 1056 | |
| 1057 | // Test streaming functionality in FiberHandler using SendStreamWriter. |
| 1058 | fiberH := func(c fiber.Ctx) error { |
| 1059 | c.Status(fiber.StatusTeapot) |
| 1060 | return c.SendStreamWriter(func(w *bufio.Writer) { |
| 1061 | w.WriteString("Hello ") //nolint:errcheck // not needed |
| 1062 | w.Flush() //nolint:errcheck // not needed |
| 1063 | time.Sleep(200 * time.Millisecond) // Simulate a long operation |
| 1064 | w.WriteString("World!") //nolint:errcheck // not needed |
| 1065 | }) |
| 1066 | } |
| 1067 | handlerFunc := FiberHandlerFunc(fiberH) |
| 1068 | |
| 1069 | r := &http.Request{ |
| 1070 | Method: http.MethodGet, |
| 1071 | RequestURI: "/test", |
| 1072 | Header: make(http.Header), |
| 1073 | Body: http.NoBody, |
| 1074 | } |
| 1075 | |
| 1076 | w := &netHTTPResponseWriter{} |
| 1077 | handlerFunc.ServeHTTP(w, r) |
| 1078 | |
| 1079 | // Should return the error status |
| 1080 | require.Equal(t, fiber.StatusTeapot, w.StatusCode()) |
| 1081 | require.Equal(t, "Hello World!", string(w.body)) |
| 1082 | } |
| 1083 | |
| 1084 | func Test_FiberHandler_ClosesBodyStream(t *testing.T) { |
| 1085 | t.Parallel() |
nothing calls this directly
no test coverage detected