MCPcopy Index your code
hub / github.com/kataras/iris / TestStaticCache

Function TestStaticCache

cache/browser_test.go:31–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestStaticCache(t *testing.T) {
32 // test change the time format, which is not recommended but can be done.
33 app := iris.New().Configure(iris.WithTimeFormat("02 Jan 2006 15:04:05 GMT"))
34
35 cacheDur := 30 * (24 * time.Hour)
36 var expectedTime time.Time
37 app.Get("/", cache.StaticCache(cacheDur), func(ctx iris.Context) {
38 expectedTime = time.Now()
39 ctx.WriteString("static_cache")
40 })
41
42 // tests
43 e := httptest.New(t, app)
44 r := e.GET("/").Expect().Status(httptest.StatusOK)
45 r.Body().IsEqual("static_cache")
46
47 r.Header(cache.ExpiresHeaderKey).Equal(expectedTime.Add(cacheDur).Format(app.ConfigurationReadOnly().GetTimeFormat()))
48 cacheControlHeaderValue := "public, max-age=" + strconv.Itoa(int(cacheDur.Seconds()))
49 r.Header(context.CacheControlHeaderKey).Equal(cacheControlHeaderValue)
50}
51
52func TestCache304(t *testing.T) {
53 // t.Parallel()

Callers

nothing calls this directly

Calls 14

NewFunction · 0.92
NewMethod · 0.80
WriteStringMethod · 0.80
StatusMethod · 0.80
ConfigureMethod · 0.65
GetMethod · 0.65
NowMethod · 0.65
BodyMethod · 0.65
FormatMethod · 0.65
GetTimeFormatMethod · 0.65
ConfigurationReadOnlyMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…