-
values := map[string]string{"name": "kataras", "package": "iris"}
Put("/set", func(ctx *Context) {
for k, v := range values {
// here I add the cookies
}
})
Get("/get_no_getflash", func(ctx *Context) {
//here nothing happens just an empty handler
})
//e = here preparation of the tester, nothing special
e.PUT("/set").Expect().Status(StatusOK).Cookies().Length().Equal(len(values)) // this works
e.GET("/get_no_getflash").Expect().Status(StatusOK).Cookies().Length().Equal(len(values)) // this doesn't works, it returns 0 cookies len
// so I though maybe the httpexpect doesn't keeps the cookies and reset them on-each request, although it should be keep cookies like a normal client, and so I tested this simple thing:
e.GET("/get_no_getflash").WithCookies(values).Expect().Status(StatusOK).Cookies().Length().Equal(len(values)) // this doesnt works also, it returns 0 cookies len |
Beta Was this translation helpful? Give feedback.
Answered by
gavv
Jul 6, 2016
Replies: 1 comment
-
httpexpect (actually, Session cookies from previous responses are available through |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gavv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cookies()
returns a list of cookies fromSet-Cookie
headers of current response.httpexpect (actually,
http.Client
) does keep cookies from previous responses, but they are not available throughCookie()
andCookies()
methods. The logic behind that is that these methods are response assertions, not session assertions, so they return response cookies, not session cookies.Session cookies from previous responses are available through
http.Client.Jar
passed to httpexpect.