photoprism/internal/config/test_test.go
Michael Mayer 3698a860c6 CI: Improve stability when running unit tests in parallel
Adds SQLite memory namespaces to avoid potential conflicts.
2022-03-31 17:55:40 +02:00

58 lines
1.1 KiB
Go

package config
import (
"testing"
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/pkg/fs"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli"
)
func TestConfig_TestdataPath2(t *testing.T) {
assert.Equal(t, "/xxx/testdata", testDataPath("/xxx"))
}
func TestTestCliContext(t *testing.T) {
result := CliTestContext()
assert.IsType(t, new(cli.Context), result)
}
func TestTestConfig(t *testing.T) {
c := TestConfig()
assert.IsType(t, new(Config), c)
assert.IsType(t, &gorm.DB{}, c.Db())
}
func TestNewTestOptions(t *testing.T) {
c := NewTestOptions("config")
assert.IsType(t, new(Options), c)
assert.Equal(t, fs.Abs("../../assets"), c.AssetsPath)
assert.True(t, c.Debug)
}
func TestNewTestOptionsError(t *testing.T) {
c := NewTestOptionsError()
assert.IsType(t, new(Options), c)
assert.Equal(t, fs.Abs("../.."), c.AssetsPath)
assert.Equal(t, fs.Abs("../../storage/testdata/cache"), c.CachePath)
assert.False(t, c.Debug)
}
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)
}