23 lines
372 B
Go
23 lines
372 B
Go
package lib
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"path"
|
|
"testing"
|
|
|
|
"gitea/price-is-wrong/src/lib/db"
|
|
|
|
_ "github.com/glebarez/sqlite"
|
|
)
|
|
|
|
func NewTestCtx(t *testing.T) context.Context {
|
|
d := t.TempDir()
|
|
b, err := sql.Open("sqlite", path.Join(d, "db.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { b.Close() })
|
|
return db.Inject(context.Background(), b)
|
|
}
|