Home / Function/ Test_Cache_Post() — fiber Function Reference

Test_Cache_Post() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 924–964

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

	app := fiber.New()

	app.Use(New(Config{
		Methods: []string{fiber.MethodPost},
	}))

	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, "123", 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, "12345", string(body))
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free