From 148845bb8bf9aa6ee5c98da69f01c3f82d6bc22c Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Wed, 4 Nov 2020 02:28:38 +0100 Subject: [PATCH] Update redis_test.go --- redis/redis_test.go | 154 ++------------------------------------------ 1 file changed, 7 insertions(+), 147 deletions(-) diff --git a/redis/redis_test.go b/redis/redis_test.go index 55f36eb8..a12c8b49 100644 --- a/redis/redis_test.go +++ b/redis/redis_test.go @@ -5,7 +5,6 @@ package redis import ( "os" "testing" - "time" "github.com/gofiber/utils" ) @@ -18,159 +17,20 @@ func init() { } } -func Test_Redis_Set(t *testing.T) { - - store := New(storeConfig) - - id := "hello" - value := []byte("Hi there!") - - store.Set(id, value, 0) - - var ( - returnedValue []byte - exp int64 - ) - - store.db.QueryRow(store.sqlSelect, id).Scan(&returnedValue, &exp) - - utils.AssertEqual(t, returnedValue, value) - utils.AssertEqual(t, exp, int64(0)) - -} - -func Test_Redis_SetExpiry(t *testing.T) { - - store := New(storeConfig) - - id := "hello" - value := []byte("Hi there!") - expiry := time.Second * 10 - - store.Set(id, value, expiry) - - now := time.Now().Unix() - var ( - returnedValue []byte - exp int64 - ) - store.db.QueryRow(store.sqlSelect, id).Scan(&returnedValue, &exp) - - delta := exp - now - upperBound := int64(expiry.Seconds()) - lowerBound := upperBound - 2 - - if !(delta <= upperBound && delta > lowerBound) { - t.Fatalf("Test_SetExpiry: expiry delta out of bounds (is %d, must be %d