package mdb_test

import (
	"context"

	"zombiezen.com/go/sqlite"
	"zombiezen.com/go/sqlite/sqlitex"
)

func testdb(ctx context.Context, uri, schema string) *sqlitex.Pool {
	db, err := sqlitex.NewPool(uri, sqlitex.PoolOptions{Flags: sqlite.OpenCreate | sqlite.OpenReadWrite | sqlite.OpenMemory | sqlite.OpenSharedCache | sqlite.OpenURI})
	if err != nil {
		panic(err)
	}
	conn, err := db.Take(ctx)
	if err != nil {
		panic(err)
	}
	if err := sqlitex.ExecScript(conn, schema); err != nil {
		panic(err)
	}
	return db
}
