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

Function Test_Response_BodyStream_Fallback

client/response_test.go:750–771  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

748}
749
750func Test_Response_BodyStream_Fallback(t *testing.T) {
751 t.Parallel()
752 t.Run("non-streaming response fallback to bytes.Reader", func(t *testing.T) {
753 t.Parallel()
754 server := startTestServer(t, func(app *fiber.App) {
755 app.Get("/regular", func(c fiber.Ctx) error {
756 return c.SendString("regular response body")
757 })
758 })
759 defer server.stop()
760 client := New().SetDial(server.dial())
761 resp, err := client.Get("http://example.com/regular")
762 require.NoError(t, err)
763 defer resp.Close()
764 require.False(t, resp.IsStreaming())
765 bodyStream := resp.BodyStream()
766 require.NotNil(t, bodyStream)
767 data, err := io.ReadAll(bodyStream)
768 require.NoError(t, err)
769 require.Equal(t, "regular response body", string(data))
770 })
771}
772
773func Test_Response_IsStreaming(t *testing.T) {
774 t.Parallel()

Callers

nothing calls this directly

Calls 10

startTestServerFunction · 0.85
stopMethod · 0.80
dialMethod · 0.80
IsStreamingMethod · 0.80
BodyStreamMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
SetDialMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected