2019-05-06 23:18:10 +02:00
|
|
|
package config
|
2019-05-03 18:57:28 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
2020-01-12 14:00:56 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
2019-05-03 18:57:28 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTestCliContext(t *testing.T) {
|
|
|
|
result := CliTestContext()
|
|
|
|
|
|
|
|
assert.IsType(t, new(cli.Context), result)
|
|
|
|
}
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func TestTestConfig(t *testing.T) {
|
2020-04-30 15:41:47 +02:00
|
|
|
c := TestConfig()
|
2019-05-03 18:57:28 +02:00
|
|
|
|
2020-04-30 15:41:47 +02:00
|
|
|
assert.IsType(t, new(Config), c)
|
|
|
|
assert.IsType(t, &gorm.DB{}, c.Db())
|
2019-05-03 18:57:28 +02:00
|
|
|
}
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func TestNewTestParams(t *testing.T) {
|
|
|
|
c := NewTestParams()
|
2019-05-03 18:57:28 +02:00
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
assert.IsType(t, new(Params), c)
|
2019-05-03 18:57:28 +02:00
|
|
|
|
2020-01-31 15:29:06 +01:00
|
|
|
assert.Equal(t, fs.Abs("../../assets"), c.AssetsPath)
|
2020-04-30 15:41:47 +02:00
|
|
|
assert.True(t, c.Debug)
|
2019-05-03 18:57:28 +02:00
|
|
|
}
|
2019-12-22 19:21:47 +01:00
|
|
|
|
|
|
|
func TestNewTestParamsError(t *testing.T) {
|
|
|
|
c := NewTestParamsError()
|
|
|
|
|
|
|
|
assert.IsType(t, new(Params), c)
|
|
|
|
|
2020-01-31 15:29:06 +01:00
|
|
|
assert.Equal(t, fs.Abs("../.."), c.AssetsPath)
|
2020-05-31 02:09:52 +02:00
|
|
|
assert.Equal(t, fs.Abs("../../storage/testdata/cache"), c.CachePath)
|
2019-12-22 19:21:47 +01:00
|
|
|
assert.False(t, c.Debug)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewTestErrorConfig(t *testing.T) {
|
|
|
|
c := NewTestErrorConfig()
|
|
|
|
|
|
|
|
db := c.Db()
|
|
|
|
|
|
|
|
assert.IsType(t, &gorm.DB{}, db)
|
|
|
|
}
|