snippet/test/sqlite_test.go

55 lines
740 B
Go
Raw Normal View History

2021-09-03 08:44:20 +00:00
package test
import (
2021-09-04 03:03:51 +00:00
"fmt"
"math/rand"
2021-09-03 08:44:20 +00:00
"testing"
2021-09-03 14:23:46 +00:00
"myschools.me/suguo/snippet/sqlite"
2021-09-03 08:44:20 +00:00
)
type ABC struct {
A string
B string
C string
}
type CBA struct {
D string
E string
F string
}
func TestSqlite(t *testing.T) {
conf := &sqlite.Config{
DBFile: "tmp1/abc/aaaaa/abc.db",
}
if err := sqlite.Init(conf); err != nil {
t.Fatal(err)
}
db, err := sqlite.New()
if err != nil {
t.Fatal(err)
}
if db == nil {
t.Error("DB nil")
}
if err := sqlite.Migrate(&ABC{}, &CBA{}); err != nil {
t.Fatal(err)
}
}
2021-09-04 03:03:51 +00:00
func BenchmarkSqlite(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
m := rand.Intn(100) + 1
n := rand.Intn(m)
for i := 0; i < n; i++ {
fmt.Sprintf("%d", i)
}
}
})
}