2018-11-17 06:21:39 +01:00
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/fsutil"
|
2018-11-17 13:57:19 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/test"
|
2018-11-17 06:21:39 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewConfig(t *testing.T) {
|
2018-11-17 13:57:19 +01:00
|
|
|
ctx := test.CliContext()
|
2018-11-17 06:21:39 +01:00
|
|
|
|
|
|
|
assert.True(t, ctx.IsSet("assets-path"))
|
|
|
|
assert.False(t, ctx.Bool("debug"))
|
|
|
|
|
|
|
|
c := NewConfig(ctx)
|
|
|
|
|
|
|
|
assert.IsType(t, new(Config), c)
|
|
|
|
|
2018-11-17 13:57:19 +01:00
|
|
|
assert.Equal(t, fsutil.ExpandedFilename("../../assets"), c.GetAssetsPath())
|
2018-11-17 06:21:39 +01:00
|
|
|
assert.False(t, c.IsDebug())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_SetValuesFromFile(t *testing.T) {
|
2018-11-17 13:57:19 +01:00
|
|
|
c := NewConfig(test.CliContext())
|
2018-11-17 06:21:39 +01:00
|
|
|
|
2018-11-17 13:57:19 +01:00
|
|
|
c.SetValuesFromFile(fsutil.ExpandedFilename("../../configs/photoprism.yml"))
|
2018-11-17 06:21:39 +01:00
|
|
|
|
|
|
|
assert.Equal(t, "/srv/photoprism", c.GetAssetsPath())
|
|
|
|
assert.Equal(t, "/srv/photoprism/cache", c.GetCachePath())
|
|
|
|
assert.Equal(t, "/srv/photoprism/cache/thumbnails", c.GetThumbnailsPath())
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/originals", c.GetOriginalsPath())
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath())
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath())
|
2018-12-18 18:38:30 +01:00
|
|
|
assert.Equal(t, "tidb", c.GetDatabaseDriver())
|
|
|
|
assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.GetDatabaseDsn())
|
2018-11-17 06:21:39 +01:00
|
|
|
}
|