MCPcopy
hub / github.com/gofiber/fiber / Test_CookieJarHostEvictionIsDeterministic

Function Test_CookieJarHostEvictionIsDeterministic

client/cookiejar_test.go:213–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

211}
212
213func Test_CookieJarHostEvictionIsDeterministic(t *testing.T) {
214 t.Parallel()
215
216 cj := &CookieJar{hostCookies: make(map[string][]storedCookie, maxCookieJarHosts)}
217 for i := range maxCookieJarHosts {
218 host := fmt.Sprintf("host-%04d.example.com", i+1)
219 cookie := fasthttp.AcquireCookie()
220 cookie.SetKey("k")
221 cookie.SetValue("v")
222 cj.hostCookies[host] = []storedCookie{{cookie: cookie, isHostOnly: true}}
223 }
224
225 cj.ensureHostCapacityLocked("zzz.example.com", time.Now())
226
227 _, ok := cj.hostCookies["host-0001.example.com"]
228 require.False(t, ok)
229 require.Len(t, cj.hostCookies, maxCookieJarHosts-1)
230}
231
232func Test_CookieJarHostCapacityPrefersExpiredEntries(t *testing.T) {
233 t.Parallel()

Callers

nothing calls this directly

Calls 3

LenMethod · 0.65
NowMethod · 0.45

Tested by

no test coverage detected