(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestCache(t *testing.T) { |
| 118 | app := iris.New() |
| 119 | var n uint32 |
| 120 | |
| 121 | app.Use(cache.Handler(cacheDuration)) |
| 122 | |
| 123 | app.Get("/", func(ctx *context.Context) { |
| 124 | atomic.AddUint32(&n, 1) |
| 125 | ctx.Write([]byte(expectedBodyStr)) |
| 126 | }) |
| 127 | |
| 128 | var ( |
| 129 | n2 uint32 |
| 130 | expectedBodyStr2 = "This is the other" |
| 131 | ) |
| 132 | |
| 133 | app.Get("/other", func(ctx *context.Context) { |
| 134 | atomic.AddUint32(&n2, 1) |
| 135 | ctx.Write([]byte(expectedBodyStr2)) |
| 136 | }) |
| 137 | |
| 138 | e := httptest.New(t, app) |
| 139 | if err := runTest(e, "/", &n, expectedBodyStr, ""); err != nil { |
| 140 | t.Fatalf(t.Name()+": %v", err) |
| 141 | } |
| 142 | |
| 143 | if err := runTest(e, "/other", &n2, expectedBodyStr2, ""); err != nil { |
| 144 | t.Fatalf(t.Name()+" other: %v", err) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // This works but we have issue on golog.SetLevel and get golog.Level on httptest.New |
| 149 | // when tests are running in parallel and the loggers are used. |
nothing calls this directly
no test coverage detected
searching dependent graphs…