Home / Function/ TestCacheStorageSetError() — fiber Function Reference

TestCacheStorageSetError() — fiber Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  d940bdce_ef18_497d_cddd_12087f3abbd7["TestCacheStorageSetError()"]
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  d940bdce_ef18_497d_cddd_12087f3abbd7 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656
  764bea14_4c8a_81bd_ccd6_a1952b5d95d1["newFailingCacheStorage()"]
  d940bdce_ef18_497d_cddd_12087f3abbd7 -->|calls| 764bea14_4c8a_81bd_ccd6_a1952b5d95d1
  style d940bdce_ef18_497d_cddd_12087f3abbd7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 252–276

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

	storage := newFailingCacheStorage()
	storage.errs["set|/_GET_body"] = errors.New("boom")

	var captured error
	app := fiber.New(fiber.Config{
		ErrorHandler: func(c fiber.Ctx, err error) error {
			captured = err
			return c.Status(fiber.StatusInternalServerError).SendString("storage failure")
		},
	})

	app.Use(New(Config{Storage: storage, Expiration: time.Second}))
	app.Get("/", func(c fiber.Ctx) error {
		return c.SendString("ok")
	})

	resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
	require.NoError(t, err)
	require.Equal(t, fiber.StatusInternalServerError, resp.StatusCode)
	require.Error(t, captured)
	require.ErrorContains(t, captured, "cache: failed to store raw key")
}

Subdomains

Frequently Asked Questions

What does TestCacheStorageSetError() do?
TestCacheStorageSetError() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is TestCacheStorageSetError() defined?
TestCacheStorageSetError() is defined in middleware/cache/cache_test.go at line 252.
What does TestCacheStorageSetError() call?
TestCacheStorageSetError() calls 1 function(s): newFailingCacheStorage.

Analyze Your Own Codebase

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

Try Supermodel Free