2024-06-15 13:56:47 -07:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/gorilla/sessions"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2024-07-09 17:57:05 -07:00
|
|
|
|
|
|
|
"git.grosinger.net/tgrosinger/saasitone/pkg/session"
|
|
|
|
"git.grosinger.net/tgrosinger/saasitone/pkg/tests"
|
2024-06-15 13:56:47 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSession(t *testing.T) {
|
|
|
|
ctx, _ := tests.NewContext(c.Web, "/")
|
|
|
|
_, err := session.Get(ctx, "test")
|
|
|
|
assert.Equal(t, session.ErrStoreNotFound, err)
|
|
|
|
|
|
|
|
store := sessions.NewCookieStore([]byte("secret"))
|
|
|
|
err = tests.ExecuteMiddleware(ctx, Session(store))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = session.Get(ctx, "test")
|
|
|
|
assert.NotEqual(t, session.ErrStoreNotFound, err)
|
|
|
|
}
|