Home / Function/ TestCacheStorageGetError() — fiber Function Reference

TestCacheStorageGetError() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 226–250

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

	storage := newFailingCacheStorage()
	storage.errs["get|/_GET"] = 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 get key")
}

Subdomains

Frequently Asked Questions

What does TestCacheStorageGetError() do?
TestCacheStorageGetError() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is TestCacheStorageGetError() defined?
TestCacheStorageGetError() is defined in middleware/cache/cache_test.go at line 226.
What does TestCacheStorageGetError() call?
TestCacheStorageGetError() 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