Home / Function/ Test_Cache_WithSeveralRequests() — fiber Function Reference

Test_Cache_WithSeveralRequests() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 818–853

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

	app := fiber.New()

	app.Use(New(Config{
		Expiration: 10 * time.Second,
	}))

	app.Get("/:id", func(c fiber.Ctx) error {
		return c.SendString(c.Params("id"))
	})

	for range 10 {
		for i := range 10 {
			func(id int) {
				rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, fmt.Sprintf("/%d", id), http.NoBody))
				require.NoError(t, err)

				defer func(body io.ReadCloser) {
					closeErr := body.Close()
					require.NoError(t, closeErr)
				}(rsp.Body)

				idFromServ, err := io.ReadAll(rsp.Body)
				require.NoError(t, err)

				a, err := strconv.Atoi(string(idFromServ))
				require.NoError(t, err)

				// Sometimes, the id is not equal to a
				require.Equal(t, id, a)
			}(i)
		}
	}
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free