Home / Function/ Test_Cache_Get() — fiber Function Reference

Test_Cache_Get() — fiber Function Reference

Architecture documentation for the Test_Cache_Get() function in cache_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  b8aa5dfb_05a8_890c_90a9_03742b7f3b22["Test_Cache_Get()"]
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  b8aa5dfb_05a8_890c_90a9_03742b7f3b22 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656
  style b8aa5dfb_05a8_890c_90a9_03742b7f3b22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 884–922

func Test_Cache_Get(t *testing.T) {
	t.Parallel()

	app := fiber.New()

	app.Use(New())

	app.Post("/", func(c fiber.Ctx) error {
		return c.SendString(fiber.Query[string](c, "cache"))
	})

	app.Get("/get", func(c fiber.Ctx) error {
		return c.SendString(fiber.Query[string](c, "cache"))
	})

	resp, err := app.Test(httptest.NewRequest(fiber.MethodPost, "/?cache=123", http.NoBody))
	require.NoError(t, err)
	body, err := io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Equal(t, "123", string(body))

	resp, err = app.Test(httptest.NewRequest(fiber.MethodPost, "/?cache=12345", http.NoBody))
	require.NoError(t, err)
	body, err = io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Equal(t, "12345", string(body))

	resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/get?cache=123", http.NoBody))
	require.NoError(t, err)
	body, err = io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Equal(t, "123", string(body))

	resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/get?cache=12345", http.NoBody))
	require.NoError(t, err)
	body, err = io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Equal(t, "123", string(body))
}

Subdomains

Frequently Asked Questions

What does Test_Cache_Get() do?
Test_Cache_Get() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_Get() defined?
Test_Cache_Get() is defined in middleware/cache/cache_test.go at line 884.

Analyze Your Own Codebase

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

Try Supermodel Free