1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

minor: sessions testing: fix travis by using InRange for cookie's MaxAge

Former-commit-id: a1d6096aec0d716539e1b4b35547c7b3f05bbd3f
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-04-13 10:01:51 +03:00
parent 989ac436e8
commit 629ae3c688
2 changed files with 15 additions and 3 deletions

View File

@@ -248,7 +248,7 @@ func TestSessionsUpdateExpiration(t *testing.T) {
e := httptest.New(t, app, httptest.URL("http://example.com"))
tt := e.GET("/set").Expect().Status(httptest.StatusOK)
tt.Cookie(cookieName).MaxAge().Equal(30 * time.Minute)
tt.Cookie(cookieName).MaxAge().InRange(29*time.Minute, 30*time.Minute)
sessionID := tt.JSON().Object().Raw()["sessionID"].(string)
expectedResponse := response{SessionID: sessionID, Logged: true}
@@ -256,11 +256,11 @@ func TestSessionsUpdateExpiration(t *testing.T) {
JSON().Equal(expectedResponse)
tt = e.POST("/remember_me").Expect().Status(httptest.StatusOK)
tt.Cookie(cookieName).MaxAge().Equal(24 * time.Hour)
tt.Cookie(cookieName).MaxAge().InRange(23*time.Hour, 24*time.Hour)
tt.JSON().Equal(expectedResponse)
// Test call `UpdateExpiration` when cookie is firstly created.
e.GET("/destroy").Expect().Status(httptest.StatusOK)
e.POST("/remember_me").Expect().Status(httptest.StatusOK).
Cookie(cookieName).MaxAge().Equal(24 * time.Hour)
Cookie(cookieName).MaxAge().InRange(23*time.Hour, 24*time.Hour)
}