package memory import ( "testing" "time" "github.com/gofiber/fiber/v2/utils" ) func Test_Set(t *testing.T) { store := New() id := "hello" value := []byte("Hi there!") store.Set(id, value, 0) utils.AssertEqual(t, entry{value, 0}, store.db[id]) } func Test_SetExpiry(t *testing.T) { store := New() id := "hello" value := []byte("Hi there!") expiry := time.Second * 10 store.Set(id, value, expiry) now := time.Now().Unix() fromStore, found := store.db[id] utils.AssertEqual(t, true, found) delta := fromStore.expiry - 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