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) {
|
|
|
|
result := TestConfig()
|
2019-05-03 18:57:28 +02:00
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
assert.IsType(t, new(Config), result)
|
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)
|
2019-05-03 18:57:28 +02:00
|
|
|
assert.False(t, c.Debug)
|
|
|
|
}
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func TestNewTestConfig(t *testing.T) {
|
|
|
|
c := NewTestConfig()
|
2019-05-03 18:57:28 +02:00
|
|
|
|
|
|
|
db := c.Db()
|
|
|
|
|
|
|
|
assert.IsType(t, &gorm.DB{}, db)
|
|
|
|
}
|
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)
|
2019-12-22 19:21:47 +01:00
|
|
|
assert.Equal(t, "../../assets/testdata/cache", c.CachePath)
|
|
|
|
assert.False(t, c.Debug)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewTestErrorConfig(t *testing.T) {
|
|
|
|
c := NewTestErrorConfig()
|
|
|
|
|
|
|
|
db := c.Db()
|
|
|
|
|
|
|
|
assert.IsType(t, &gorm.DB{}, db)
|
|
|
|
}
|