From 3b02449903e2b0eff9d56f01529c980cddf4ddf3 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 9 Oct 2020 11:35:05 +0200 Subject: [PATCH] Backend: Fix config tests Signed-off-by: Michael Mayer --- internal/config/filenames_test.go | 12 +++++++++--- internal/config/test.go | 4 ---- internal/config/test_test.go | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/config/filenames_test.go b/internal/config/filenames_test.go index 2c68f8469..85f90347e 100644 --- a/internal/config/filenames_test.go +++ b/internal/config/filenames_test.go @@ -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) } } diff --git a/internal/config/test.go b/internal/config/test.go index fc5df9a84..689bde803 100644 --- a/internal/config/test.go +++ b/internal/config/test.go @@ -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 } diff --git a/internal/config/test_test.go b/internal/config/test_test.go index 25fcc3820..568c67f19 100644 --- a/internal/config/test_test.go +++ b/internal/config/test_test.go @@ -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)