use testify in "model/session_test.go" (#12644)
Migrate tests from "model/session_test.go" to use testify
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
07cd32779d
Коммит
0652e121ec
@@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -45,21 +46,16 @@ func TestSessionJson(t *testing.T) {
|
|||||||
json := session.ToJson()
|
json := session.ToJson()
|
||||||
rsession := SessionFromJson(strings.NewReader(json))
|
rsession := SessionFromJson(strings.NewReader(json))
|
||||||
|
|
||||||
if rsession.Id != session.Id {
|
require.Equal(t, rsession.Id, session.Id, "Ids do not match")
|
||||||
t.Fatal("Ids do not match")
|
|
||||||
}
|
|
||||||
|
|
||||||
session.Sanitize()
|
session.Sanitize()
|
||||||
|
|
||||||
if session.IsExpired() {
|
require.False(t, session.IsExpired(), "Shouldn't expire")
|
||||||
t.Fatal("Shouldn't expire")
|
|
||||||
}
|
|
||||||
|
|
||||||
session.ExpiresAt = GetMillis()
|
session.ExpiresAt = GetMillis()
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
if !session.IsExpired() {
|
|
||||||
t.Fatal("Should expire")
|
require.True(t, session.IsExpired(), "Should expire")
|
||||||
}
|
|
||||||
|
|
||||||
session.SetExpireInDays(10)
|
session.SetExpireInDays(10)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user