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-12-21 03:25:09 +01:00
|
|
|
assert.Equal(t, fsutil.ExpandedFilename("../../assets"), c.AssetsPath())
|
2018-12-21 02:49:45 +01:00
|
|
|
assert.False(t, c.Debug())
|
2018-11-17 06:21:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-05-01 14:54:11 +02:00
|
|
|
err := c.SetValuesFromFile(fsutil.ExpandedFilename("../../configs/photoprism.yml"))
|
|
|
|
|
|
|
|
assert.Nil(t, err)
|
2018-11-17 06:21:39 +01:00
|
|
|
|
2018-12-21 03:25:09 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism", c.AssetsPath())
|
2018-12-21 03:23:47 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism/cache", c.CachePath())
|
2018-12-21 03:24:22 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism/cache/thumbnails", c.ThumbnailsPath())
|
2018-12-21 03:21:21 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism/photos/originals", c.OriginalsPath())
|
2018-12-21 03:21:49 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism/photos/import", c.ImportPath())
|
2018-12-21 03:22:25 +01:00
|
|
|
assert.Equal(t, "/srv/photoprism/photos/export", c.ExportPath())
|
2018-12-21 08:44:13 +01:00
|
|
|
assert.Equal(t, "internal", c.DatabaseDriver())
|
2019-05-01 14:54:11 +02:00
|
|
|
assert.Equal(t, "root:photoprism@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn())
|
2018-11-17 06:21:39 +01:00
|
|
|
}
|