Home / Function/ Test_App_Test_CloseFail() — fiber Function Reference

Test_App_Test_CloseFail() — fiber Function Reference

Architecture documentation for the Test_App_Test_CloseFail() function in app_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  14f4468a_c50a_a3e5_0375_c0f78ae59d34["Test_App_Test_CloseFail()"]
  e728fdd2_242f_706b_c1d2_041b3d6badb5["app_test.go"]
  14f4468a_c50a_a3e5_0375_c0f78ae59d34 -->|defined in| e728fdd2_242f_706b_c1d2_041b3d6badb5
  style 14f4468a_c50a_a3e5_0375_c0f78ae59d34 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

app_test.go lines 2589–2619

func Test_App_Test_CloseFail(t *testing.T) {
	// Note: Test cannot run in parallel due to
	// overriding the httpReadResponse global variable.
	// t.Parallel()

	// Override httpReadResponse temporarily
	oldHTTPReadResponse := httpReadResponse
	defer func() {
		httpReadResponse = oldHTTPReadResponse
	}()

	httpReadResponse = func(r *bufio.Reader, req *http.Request) (*http.Response, error) {
		resp, err := http.ReadResponse(r, req)
		_ = resp.Body.Close() //nolint:errcheck // It is fine to ignore the error here
		resp.Body = &doubleCloseBody{}
		return resp, err //nolint:wrapcheck // unnecessary to wrap it
	}

	app := New()
	hints := []string{"<https://cdn.com>; rel=preload; as=script"}
	app.Get("/early", func(c Ctx) error {
		err := c.SendEarlyHints(hints)
		require.NoError(t, err)
		return c.Status(StatusOK).SendString("done")
	})

	req := httptest.NewRequest(MethodGet, "/early", http.NoBody)
	_, err := app.Test(req)

	require.ErrorIs(t, err, errDoubleClose)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_App_Test_CloseFail() do?
Test_App_Test_CloseFail() is a function in the fiber codebase, defined in app_test.go.
Where is Test_App_Test_CloseFail() defined?
Test_App_Test_CloseFail() is defined in app_test.go at line 2589.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free