From 96103e4d7c64359ee89f0d27b0051908fc06f723 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Mon, 1 Oct 2018 22:50:20 +0200 Subject: [PATCH] fetch the right cookie --- session_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/session_test.go b/session_test.go index b32934b..832bc9d 100644 --- a/session_test.go +++ b/session_test.go @@ -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") + } + +}