mirror of
https://github.com/photoprism/photoprism.git
synced 2025-10-05 16:57:17 +08:00
Add db controlled mutex to prevent database init occuring during another test as this breaks the tests on MariaDB
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/photoprism/get"
|
||||
"github.com/photoprism/photoprism/internal/testextras"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -18,6 +19,14 @@ func TestMain(m *testing.M) {
|
||||
log.SetLevel(logrus.TraceLevel)
|
||||
event.AuditLog = log
|
||||
|
||||
caller := "internal/commands/commands_test.go/TestMain"
|
||||
dbc, err := testextras.AcquireDBMutex(log, caller)
|
||||
if err != nil {
|
||||
log.Error("FAIL")
|
||||
os.Exit(1)
|
||||
}
|
||||
defer testextras.UnlockDBMutex(dbc.Db())
|
||||
|
||||
c := config.NewTestConfig("commands")
|
||||
get.SetConfig(c)
|
||||
|
||||
@@ -29,6 +38,8 @@ func TestMain(m *testing.M) {
|
||||
// Run unit tests.
|
||||
code := m.Run()
|
||||
|
||||
testextras.ReleaseDBMutex(dbc.Db(), log, caller, code)
|
||||
|
||||
// Close database connection.
|
||||
c.CloseDb()
|
||||
|
||||
|
Reference in New Issue
Block a user