2019-12-11 16:55:18 +01:00
|
|
|
package entity
|
2019-05-16 04:03:55 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2021-10-06 12:16:52 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2019-12-11 19:11:44 +01:00
|
|
|
"github.com/sirupsen/logrus"
|
2019-05-16 04:03:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
2019-12-11 19:11:44 +01:00
|
|
|
log = logrus.StandardLogger()
|
|
|
|
log.SetLevel(logrus.DebugLevel)
|
2020-04-30 20:07:03 +02:00
|
|
|
|
2020-07-21 14:43:45 +02:00
|
|
|
if err := os.Remove(".test.db"); err == nil {
|
|
|
|
log.Debugln("removed .test.db")
|
|
|
|
}
|
|
|
|
|
2020-05-30 14:52:47 +02:00
|
|
|
db := InitTestDb(os.Getenv("PHOTOPRISM_TEST_DRIVER"), os.Getenv("PHOTOPRISM_TEST_DSN"))
|
|
|
|
defer db.Close()
|
2020-04-30 20:07:03 +02:00
|
|
|
|
2019-05-16 04:03:55 +02:00
|
|
|
code := m.Run()
|
2020-04-30 20:07:03 +02:00
|
|
|
|
2019-05-16 04:03:55 +02:00
|
|
|
os.Exit(code)
|
|
|
|
}
|
2021-10-06 12:16:52 +02:00
|
|
|
|
|
|
|
func TestTypeString(t *testing.T) {
|
|
|
|
assert.Equal(t, "unknown", TypeString(""))
|
|
|
|
assert.Equal(t, "foo", TypeString("foo"))
|
|
|
|
}
|