Home / Function/ Test_ParseMaxAge() — fiber Function Reference

Test_ParseMaxAge() — fiber Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 2983–3012

func Test_ParseMaxAge(t *testing.T) {
	t.Parallel()
	tests := []struct {
		header string
		expect time.Duration
		ok     bool
	}{
		{"max-age=60", 60 * time.Second, true},
		{"public, max-age=86400", 86400 * time.Second, true},
		{"no-store", 0, false},
		{"max-age=invalid", 0, false},
		{"public, s-maxage=100, max-age=50", 50 * time.Second, true},
		{"MAX-AGE=20", 20 * time.Second, true},
		{"public , max-age=0", 0, true},
		{"public , max-age", 0, false},
	}

	for _, tt := range tests {
		t.Run(tt.header, func(t *testing.T) {
			t.Parallel()
			d, ok := parseMaxAge(tt.header)
			if tt.ok != ok {
				t.Fatalf("expected ok=%v got %v", tt.ok, ok)
			}
			if ok && d != tt.expect {
				t.Fatalf("expected %v got %v", tt.expect, d)
			}
		})
	}
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free