mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
43 lines
1,016 B
Go
43 lines
1,016 B
Go
package avatar
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
"github.com/photoprism/photoprism/internal/photoprism/get"
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
|
)
|
|
|
|
// TestMain executes testMain returning it's results. It is done this way so that defer can be used to cleanup.
|
|
func TestMain(m *testing.M) {
|
|
os.Exit(testMain(m))
|
|
}
|
|
|
|
func testMain(m *testing.M) (code int) {
|
|
log = logrus.StandardLogger()
|
|
log.SetLevel(logrus.TraceLevel)
|
|
|
|
tempDir, err := os.MkdirTemp("", "avatar-test")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer os.RemoveAll(tempDir)
|
|
|
|
c := config.NewMinimalTestConfigWithDb("avatar", tempDir)
|
|
defer c.CleanupTestFolder()
|
|
defer func() {
|
|
if err := c.CloseDb(); err != nil {
|
|
log.Errorf("close db: %v", err)
|
|
}
|
|
// Remove temporary SQLite files after running the tests.
|
|
fs.PurgeTestDbFiles(".", false)
|
|
}()
|
|
get.SetConfig(c)
|
|
photoprism.SetConfig(c)
|
|
|
|
return m.Run()
|
|
}
|