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

Function Test_Bind_Cookie_Map

bind_test.go:1971–1999  ·  view source on GitHub ↗

go test -run Test_Bind_Cookie_Map -v

(t *testing.T)

Source from the content-addressed store, hash-verified

1969
1970// go test -run Test_Bind_Cookie_Map -v
1971func Test_Bind_Cookie_Map(t *testing.T) {
1972 t.Parallel()
1973
1974 app := New(Config{
1975 EnableSplittingOnParsers: true,
1976 })
1977 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1978
1979 c.Request().SetBody([]byte(``))
1980 c.Request().Header.SetContentType("")
1981
1982 c.Request().Header.SetCookie("id", "1")
1983 c.Request().Header.SetCookie("Name", "John Doe")
1984 c.Request().Header.SetCookie("Hobby", "golang,fiber")
1985 q := make(map[string][]string)
1986 require.NoError(t, c.Bind().Cookie(&q))
1987 require.Len(t, q["Hobby"], 2)
1988
1989 c.Request().Header.DelCookie("hobby")
1990 c.Request().Header.SetCookie("Hobby", "golang,fiber,go")
1991 q = make(map[string][]string)
1992 require.NoError(t, c.Bind().Cookie(&q))
1993 require.Len(t, q["Hobby"], 3)
1994
1995 empty := make(map[string][]string)
1996 c.Request().Header.DelCookie("hobby")
1997 require.NoError(t, c.Bind().Query(&empty))
1998 require.Empty(t, empty["Hobby"])
1999}
2000
2001// go test -run Test_Bind_Cookie_WithSetParserDecoder -v
2002func Test_Bind_Cookie_WithSetParserDecoder(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AcquireCtxMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
CookieMethod · 0.65
BindMethod · 0.65
LenMethod · 0.65
QueryMethod · 0.65
SetCookieMethod · 0.45

Tested by

no test coverage detected