saasitone/pkg/session/session_test.go

24 lines
506 B
Go
Raw Permalink Normal View History

2024-06-15 13:56:47 -07:00
package session
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gorilla/sessions"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
)
func TestGetStore(t *testing.T) {
e := echo.New()
req := httptest.NewRequest(http.MethodGet, "/", nil)
ctx := e.NewContext(req, httptest.NewRecorder())
_, err := Get(ctx, "test")
assert.Equal(t, ErrStoreNotFound, err)
Store(ctx, sessions.NewCookieStore([]byte("secret")))
_, err = Get(ctx, "test")
assert.NoError(t, err)
}