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

Function Test_App_Test_response_error

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

Source from the content-addressed store, hash-verified

2956}
2957
2958func Test_App_Test_response_error(t *testing.T) {
2959 // Note: Test cannot run in parallel due to
2960 // overriding the httpReadResponse global variable.
2961 // t.Parallel()
2962
2963 // Override httpReadResponse temporarily
2964 oldHTTPReadResponse := httpReadResponse
2965 defer func() {
2966 httpReadResponse = oldHTTPReadResponse
2967 }()
2968 httpReadResponse = func(_ *bufio.Reader, _ *http.Request) (*http.Response, error) {
2969 return nil, errErrorReader
2970 }
2971
2972 app := New()
2973 app.Get("/", func(c Ctx) error {
2974 return c.SendStatus(StatusOK)
2975 })
2976
2977 _, err := app.Test(httptest.NewRequest(MethodGet, "/", http.NoBody), TestConfig{
2978 Timeout: 0,
2979 FailOnTimeout: false,
2980 })
2981 require.ErrorIs(t, err, errErrorReader)
2982}
2983
2984type errorReadCloser int
2985

Callers

nothing calls this directly

Calls 4

TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStatusMethod · 0.65

Tested by

no test coverage detected