photoprism/internal/query/query_test.go
Michael Mayer 3aad02501f Run unit tests in separate databases to avoid conflicts
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-08 19:34:29 +02:00

31 lines
472 B
Go

package query
import (
"os"
"strings"
"testing"
"github.com/photoprism/photoprism/internal/entity"
"github.com/sirupsen/logrus"
)
func TestMain(m *testing.M) {
log = logrus.StandardLogger()
log.SetLevel(logrus.DebugLevel)
dsn := os.Getenv("PHOTOPRISM_TEST_DSN")
if dsn == "" {
panic("database dsn is empty")
}
db := entity.InitTestDb(strings.Replace(dsn, "/photoprism", "/query", 1))
code := m.Run()
if db != nil {
db.Close()
}
os.Exit(code)
}