Home / Function/ Test_Static_Disable_Cache() — fiber Function Reference

Test_Static_Disable_Cache() — fiber Function Reference

Architecture documentation for the Test_Static_Disable_Cache() function in static_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  503cc71c_5d76_4eb5_b8eb_c87d69db7751["Test_Static_Disable_Cache()"]
  f26a2d79_1e01_f027_82eb_45c4308747e8["static_test.go"]
  503cc71c_5d76_4eb5_b8eb_c87d69db7751 -->|defined in| f26a2d79_1e01_f027_82eb_45c4308747e8
  style 503cc71c_5d76_4eb5_b8eb_c87d69db7751 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/static/static_test.go lines 141–183

func Test_Static_Disable_Cache(t *testing.T) {
	// Skip on Windows. It's not possible to delete a file that is in use.
	if runtime.GOOS == winOS {
		t.SkipNow()
	}

	t.Parallel()

	app := fiber.New()

	file, err := os.Create("../../.github/test.txt")
	require.NoError(t, err)
	_, err = file.WriteString("Hello, World!")
	require.NoError(t, err)
	require.NoError(t, file.Close())

	// Remove the file even if the test fails
	defer func() {
		_ = os.Remove("../../.github/test.txt") //nolint:errcheck // not needed
	}()

	app.Get("/*", New("../../.github/", Config{
		CacheDuration: -1,
	}))

	resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/test.txt", http.NoBody))
	require.NoError(t, err, "app.Test(req)")
	require.Empty(t, resp.Header.Get(fiber.HeaderCacheControl), "CacheControl Control")

	body, err := io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Contains(t, string(body), "Hello, World!")

	require.NoError(t, os.Remove("../../.github/test.txt"))

	resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/test.txt", http.NoBody))
	require.NoError(t, err, "app.Test(req)")
	require.Empty(t, resp.Header.Get(fiber.HeaderCacheControl), "CacheControl Control")

	body, err = io.ReadAll(resp.Body)
	require.NoError(t, err)
	require.Equal(t, "Not Found", string(body))
}

Domain

Subdomains

Frequently Asked Questions

What does Test_Static_Disable_Cache() do?
Test_Static_Disable_Cache() is a function in the fiber codebase, defined in middleware/static/static_test.go.
Where is Test_Static_Disable_Cache() defined?
Test_Static_Disable_Cache() is defined in middleware/static/static_test.go at line 141.

Analyze Your Own Codebase

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

Try Supermodel Free