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

Function Test_App_ReadBodyStream

app_test.go:2810–2823  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2808}
2809
2810func Test_App_ReadBodyStream(t *testing.T) {
2811 t.Parallel()
2812 app := New(Config{StreamRequestBody: true})
2813 app.Post("/", func(c Ctx) error {
2814 // Calling c.Body() automatically reads the entire stream.
2815 return c.SendString(fmt.Sprintf("%v %s", c.Request().IsBodyStream(), c.Body()))
2816 })
2817 testString := "this is a test"
2818 resp, err := app.Test(httptest.NewRequest(MethodPost, "/", bytes.NewBufferString(testString)))
2819 require.NoError(t, err, "app.Test(req)")
2820 body, err := io.ReadAll(resp.Body)
2821 require.NoError(t, err, "io.ReadAll(resp.Body)")
2822 require.Equal(t, "true "+testString, string(body))
2823}
2824
2825func Test_App_DisablePreParseMultipartForm(t *testing.T) {
2826 t.Parallel()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
PostMethod · 0.65
SendStringMethod · 0.65
RequestMethod · 0.65
BodyMethod · 0.65

Tested by

no test coverage detected