(t *testing.T)
| 3051 | } |
| 3052 | |
| 3053 | func Test_App_Test_CloseFail(t *testing.T) { |
| 3054 | // Note: Test cannot run in parallel due to |
| 3055 | // overriding the httpReadResponse global variable. |
| 3056 | // t.Parallel() |
| 3057 | |
| 3058 | // Override httpReadResponse temporarily |
| 3059 | oldHTTPReadResponse := httpReadResponse |
| 3060 | defer func() { |
| 3061 | httpReadResponse = oldHTTPReadResponse |
| 3062 | }() |
| 3063 | |
| 3064 | httpReadResponse = func(r *bufio.Reader, req *http.Request) (*http.Response, error) { |
| 3065 | resp, err := http.ReadResponse(r, req) |
| 3066 | _ = resp.Body.Close() //nolint:errcheck // It is fine to ignore the error here |
| 3067 | resp.Body = &doubleCloseBody{} |
| 3068 | return resp, err //nolint:wrapcheck // unnecessary to wrap it |
| 3069 | } |
| 3070 | |
| 3071 | app := New() |
| 3072 | hints := []string{"<https://cdn.com>; rel=preload; as=script"} |
| 3073 | app.Get("/early", func(c Ctx) error { |
| 3074 | err := c.SendEarlyHints(hints) |
| 3075 | require.NoError(t, err) |
| 3076 | return c.Status(StatusOK).SendString("done") |
| 3077 | }) |
| 3078 | |
| 3079 | req := httptest.NewRequest(MethodGet, "/early", http.NoBody) |
| 3080 | _, err := app.Test(req) |
| 3081 | |
| 3082 | require.ErrorIs(t, err, errDoubleClose) |
| 3083 | } |
| 3084 | |
| 3085 | func Test_App_SetTLSHandler(t *testing.T) { |
| 3086 | t.Parallel() |
nothing calls this directly
no test coverage detected