(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func 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 | |
| 52 | func TestCache304(t *testing.T) { |
| 53 | // t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…