2020-01-05 14:18:40 +01:00
|
|
|
package query
|
2019-12-11 08:18:48 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2020-05-08 19:34:29 +02:00
|
|
|
"strings"
|
2019-12-11 08:18:48 +01:00
|
|
|
"testing"
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
2019-12-11 08:18:48 +01:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
log = logrus.StandardLogger()
|
|
|
|
log.SetLevel(logrus.DebugLevel)
|
2020-04-30 22:39:38 +02:00
|
|
|
|
2020-05-08 16:36:09 +02:00
|
|
|
dsn := os.Getenv("PHOTOPRISM_TEST_DSN")
|
|
|
|
|
|
|
|
if dsn == "" {
|
|
|
|
panic("database dsn is empty")
|
|
|
|
}
|
|
|
|
|
2020-05-08 19:34:29 +02:00
|
|
|
db := entity.InitTestDb(strings.Replace(dsn, "/photoprism", "/query", 1))
|
2020-04-30 22:39:38 +02:00
|
|
|
|
2019-12-11 08:18:48 +01:00
|
|
|
code := m.Run()
|
2020-04-30 22:39:38 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
if db != nil {
|
|
|
|
db.Close()
|
|
|
|
}
|
2020-04-30 22:39:38 +02:00
|
|
|
|
2019-12-11 08:18:48 +01:00
|
|
|
os.Exit(code)
|
|
|
|
}
|