Backend: Fix config tests

Signed-off-by: Michael Mayer <michael@lastzero.net>
This commit is contained in:
Michael Mayer 2020-10-09 11:35:05 +02:00
parent f3588ec23d
commit 3b02449903
3 changed files with 13 additions and 7 deletions

View file

@ -1,6 +1,7 @@
package config
import (
"github.com/photoprism/photoprism/pkg/rnd"
"github.com/stretchr/testify/assert"
"testing"
)
@ -75,10 +76,15 @@ func TestConfig_TestdataPath(t *testing.T) {
}
func TestConfig_CreateDirectories(t *testing.T) {
c := NewConfig(CliTestContext())
err := c.CreateDirectories()
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
if err != nil {
c := &Config{
params: NewTestParams(),
token: rnd.Token(8),
}
if err := c.CreateDirectories(); err != nil {
t.Fatal(err)
}
}

View file

@ -146,10 +146,6 @@ func NewTestConfig() *Config {
func NewTestErrorConfig() *Config {
c := &Config{params: NewTestParamsError()}
if err := c.Init(); err != nil {
log.Fatalf("config: %s", err.Error())
}
return c
}

View file

@ -48,6 +48,10 @@ func TestNewTestParamsError(t *testing.T) {
func TestNewTestErrorConfig(t *testing.T) {
c := NewTestErrorConfig()
if err := c.connectDb(); err != nil {
t.Fatal(err)
}
db := c.Db()
assert.IsType(t, &gorm.DB{}, db)