Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
itsumura-h committed Feb 28, 2024
1 parent e98c30f commit b56c4b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/basolato/core/security/session_db/redis_session_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ proc new*(_:type RedisSessionDb, sessionId=""):Future[RedisSessionDb] {.async.}
sessionId

let conn = openAsync(REDIS_IP, Port(REDIS_PORT)).await
discard conn.expire(id, SESSION_TIME * 60).await

let sessionDb = RedisSessionDb(
conn: conn,
id:id,
)
sessionDb.setStr("session_id", id).await
discard sessionDb.conn.expire(id, SESSION_TIME * 60).await
return sessionDb


Expand Down
5 changes: 2 additions & 3 deletions tests/auth/test_redis_session_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ suite("redis session db"):

test("new with empty should regenerate id"):
let session = RedisSessionDb.new("").waitFor().toInterface()
token = session.getToken().waitFor()
let token = session.getToken().waitFor()
check token.len == 256

test("new with invalid id should regenerate id"):
let session = RedisSessionDb.new("invalid").waitFor().toInterface()
token = session.getToken().waitFor()
let token = session.getToken().waitFor()
check token.len == 256

test("setStr / getStr"):
let session = RedisSessionDb.new(token).waitFor().toInterface()
session.setStr("str", "value").waitFor()
check session.getStr("str").waitFor() == "value"


test("setJson / getJson"):
let session = RedisSessionDb.new(token).waitFor().toInterface()
session.setJson("json", %*{"key": "value"}).waitFor()
Expand Down

0 comments on commit b56c4b6

Please sign in to comment.