CLI: Refactor tests and config initialization

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2022-10-04 12:27:40 +02:00
parent e2b315d79d
commit c7be7c43eb
22 changed files with 85 additions and 84 deletions

View File

@@ -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)
}