fixed new logic

This commit is contained in:
Darko Luketic
2020-04-02 21:32:02 +02:00
parent 78b84a1fa0
commit 1022c2d36c
3 changed files with 14 additions and 58 deletions

View File

@ -44,14 +44,14 @@ func TestFlashes(t *testing.T) {
var session *sessions.Session
var flashes []interface{}
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
ctx := context.Background()
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017"))
err = client.Ping(ctx, readpref.Primary())
if err != nil {
panic(err)
}
store := mongostore.NewMongoStore(client, "test", "sessions", 3*time.Second)
store := mongostore.NewMongoStore(client, "test", "sessions", 3*time.Second, []byte("hellol-worlol"))
store.Options.Path = "/"
store.Options.MaxAge = 86400 * 30 * 365
defer store.Close()
@ -199,42 +199,6 @@ func TestFlashes(t *testing.T) {
}
}
func TestCookieStoreMapPanic(t *testing.T) {
defer func() {
err := recover()
if err != nil {
t.Fatal(err)
}
}()
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017"))
err = client.Ping(ctx, readpref.Primary())
if err != nil {
panic(err)
}
store := mongostore.NewMongoStore(client, "test", "sessions", 3*time.Second, []byte("aaa0defe5d2839cbc46fc4f080cd7adc"))
store.Options.Path = "/"
store.Options.MaxAge = 86400 * 30 * 365
defer store.Close()
req, err := http.NewRequest("GET", "http://www.example.com", nil)
if err != nil {
t.Fatal("failed to create request", err)
}
w := httptest.NewRecorder()
session := sessions.NewSession(store, "hello")
session.Values["data"] = "hello-world"
err = session.Save(req, w)
if err != nil {
t.Fatal("failed to save session", err)
}
}
func init() {
gob.Register(FlashMessage{})
}