go test -run Test_Bind_Cookie_Map -v
(t *testing.T)
| 1969 | |
| 1970 | // go test -run Test_Bind_Cookie_Map -v |
| 1971 | func 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 |
| 2002 | func Test_Bind_Cookie_WithSetParserDecoder(t *testing.T) { |