🎑 update sqlite3

This commit is contained in:
Fenny
2020-11-01 10:52:23 +01:00
parent a7ba88a576
commit 127aa2a67d
20 changed files with 216 additions and 457 deletions

View File

@@ -4,23 +4,18 @@ import (
"testing"
"time"
"github.com/gofiber/fiber/v2/utils"
"github.com/gofiber/utils"
_ "github.com/mattn/go-sqlite3"
)
func getConfig() Config {
cfg := configDefault(Config{})
cfg.FilePath = ":memory:"
return cfg
}
func Test_New(t *testing.T) {
New()
}
func Test_Get_Set(t *testing.T) {
s := New(getConfig())
s := New(Config{
FilePath: ":memory:",
})
err := s.Set("fiber-10k-stars?", []byte("yes!"), time.Duration(time.Hour*1))
utils.AssertEqual(t, nil, err)
@@ -30,12 +25,14 @@ func Test_Get_Set(t *testing.T) {
}
func Test_Expiration(t *testing.T) {
s := New(getConfig())
s := New(Config{
FilePath: ":memory:",
})
err := s.Set("fiber-20k-stars?", []byte("yes!"), time.Duration(time.Nanosecond/2))
utils.AssertEqual(t, nil, err)
b, err := s.Get("fiber-20k-stars?")
b, err := s.Get("fiber-220k-stars?")
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, b == nil)
}