This repository has been archived on 2022-07-30. You can view files and clone it, but cannot push or open issues/pull-requests.
2022-07-26 12:13:41 +00:00
|
|
|
package mdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
os.Exit(m.Run())
|
|
|
|
}
|
2022-07-26 15:13:16 +00:00
|
|
|
|
|
|
|
func testWithDB(t *testing.T, name string, inner func(t *testing.T, db *DB)) {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
root, err := os.MkdirTemp("", "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(root)
|
|
|
|
|
|
|
|
db := OpenDB(root, true)
|
|
|
|
defer db.Close()
|
|
|
|
inner(t, db)
|
|
|
|
})
|
|
|
|
}
|