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

Function TestCache

cache/cache_test.go:117–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

115}
116
117func 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.

Callers

nothing calls this directly

Calls 9

HandlerFunction · 0.92
NewFunction · 0.92
runTestFunction · 0.85
NewMethod · 0.80
FatalfMethod · 0.80
UseMethod · 0.65
GetMethod · 0.65
NameMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…