mdb/main_test.go

33 lines
593 B
Go

package mdb
/*Copyright (c) 2022, John David Lee
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
*/
import (
"math/rand"
"os"
"testing"
"time"
)
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}
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("", "")
must(err)
defer os.RemoveAll(root)
db := OpenDB(root, true)
defer db.Close()
inner(t, db)
})
}