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

Function Test_App_SmallReadBuffer

app_test.go:2746–2772  ·  view source on GitHub ↗

go test -run Test_App_SmallReadBuffer

(t *testing.T)

Source from the content-addressed store, hash-verified

2744
2745// go test -run Test_App_SmallReadBuffer
2746func Test_App_SmallReadBuffer(t *testing.T) {
2747 t.Parallel()
2748 app := New(Config{
2749 ReadBufferSize: 1,
2750 })
2751
2752 app.Get("/small-read-buffer", func(c Ctx) error {
2753 return c.SendString("I should not be sent")
2754 })
2755
2756 ln, err := net.Listen(NetworkTCP4, "127.0.0.1:0")
2757 require.NoError(t, err)
2758 addr := ln.Addr().String()
2759
2760 go func() {
2761 time.Sleep(500 * time.Millisecond)
2762 req, err := http.NewRequestWithContext(context.Background(), MethodGet, fmt.Sprintf("http://%s/small-read-buffer", addr), http.NoBody)
2763 assert.NoError(t, err)
2764 var client http.Client
2765 resp, err := client.Do(req)
2766 assert.NoError(t, err)
2767 assert.Equal(t, 431, resp.StatusCode)
2768 assert.NoError(t, app.Shutdown())
2769 }()
2770
2771 require.NoError(t, app.Listener(ln, ListenConfig{DisableStartupMessage: true}))
2772}
2773
2774func Test_App_Server(t *testing.T) {
2775 t.Parallel()

Callers

nothing calls this directly

Calls 9

DoMethod · 0.95
ListenMethod · 0.80
AddrMethod · 0.80
ShutdownMethod · 0.80
ListenerMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected