mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
CLI: Refactor tests and config initialization
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -5,9 +5,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/service"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -16,10 +18,13 @@ func TestMain(m *testing.M) {
|
||||
event.AuditLog = log
|
||||
|
||||
c := config.NewTestConfig("commands")
|
||||
service.SetConfig(c)
|
||||
|
||||
InitConfig = func(ctx *cli.Context) (*config.Config, error) {
|
||||
return c, c.Init()
|
||||
}
|
||||
|
||||
code := m.Run()
|
||||
|
||||
_ = c.CloseDb()
|
||||
|
||||
os.Exit(code)
|
||||
}
|
||||
|
Reference in New Issue
Block a user