blob: 4df2a0d76529e68130c69a5d4353096ebce9ebba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
package model
import (
"strings"
"testing"
"time"
)
func TestSessionJson(t *testing.T) {
session := Session{}
session.PreSave()
json := session.ToJson()
rsession := SessionFromJson(strings.NewReader(json))
if rsession.Id != session.Id {
t.Fatal("Ids do not match")
}
session.Sanitize()
if session.IsExpired() {
t.Fatal("Shouldn't expire")
}
session.ExpiresAt = GetMillis()
time.Sleep(10 * time.Millisecond)
if !session.IsExpired() {
t.Fatal("Should expire")
}
session.SetExpireInDays(10)
}
|