Home / Function/ Test_Cache_NothingToCache() — fiber Function Reference

Test_Cache_NothingToCache() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 966–993

func Test_Cache_NothingToCache(t *testing.T) {
	t.Parallel()
	app := fiber.New()

	app.Use(New(Config{Expiration: -(time.Second * 1)}))

	count := 0
	app.Get("/", func(c fiber.Ctx) error {
		count++
		return c.SendString(strconv.Itoa(count))
	})

	resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	body, err := io.ReadAll(resp.Body)
	require.NoError(t, err)

	time.Sleep(500 * time.Millisecond)

	respCached, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	bodyCached, err := io.ReadAll(respCached.Body)
	require.NoError(t, err)

	if bytes.Equal(body, bodyCached) {
		t.Errorf("Cache should have expired: %s, %s", body, bodyCached)
	}
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free