fetch the right cookie
This commit is contained in:
parent
e06dda9a31
commit
96103e4d7c
|
@ -28,3 +28,21 @@ func TestGetSessionCookieMissingCookie(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSessionCookieCookieSet(t *testing.T) {
|
||||
mySessionKey := "12341234"
|
||||
|
||||
r, _ := http.NewRequest("GET", "/", nil)
|
||||
cookie := &http.Cookie{Name: "session", Value: mySessionKey}
|
||||
r.AddCookie(cookie)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
sessionKey, err := getSessionCookie(w, r)
|
||||
if err != nil {
|
||||
t.Errorf("err != nil in getSessionCookie")
|
||||
}
|
||||
if mySessionKey != sessionKey {
|
||||
t.Errorf("getSessionKey didn't fetch sessionKey from \"session\" cookie")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user