2019-05-06 23:18:10 +02:00
|
|
|
package config
|
2018-11-17 06:21:39 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/util"
|
2018-11-17 06:21:39 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func TestNewParams(t *testing.T) {
|
2019-05-04 05:25:00 +02:00
|
|
|
ctx := CliTestContext()
|
|
|
|
|
|
|
|
assert.True(t, ctx.IsSet("assets-path"))
|
|
|
|
assert.False(t, ctx.Bool("debug"))
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
c := NewParams(ctx)
|
2019-05-04 05:25:00 +02:00
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
assert.IsType(t, new(Params), c)
|
2019-05-04 05:25:00 +02:00
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
assert.Equal(t, util.ExpandedFilename("../../assets"), c.AssetsPath)
|
2019-05-04 05:25:00 +02:00
|
|
|
assert.False(t, c.Debug)
|
2019-05-04 09:11:33 +02:00
|
|
|
assert.False(t, c.ReadOnly)
|
2019-05-04 05:25:00 +02:00
|
|
|
}
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func TestParams_SetValuesFromFile(t *testing.T) {
|
|
|
|
c := NewParams(CliTestContext())
|
2018-11-17 06:21:39 +01:00
|
|
|
|
2019-05-04 05:25:00 +02:00
|
|
|
err := c.SetValuesFromFile("testdata/config.yml")
|
2019-05-01 14:54:11 +02:00
|
|
|
|
|
|
|
assert.Nil(t, err)
|
2018-11-17 06:21:39 +01:00
|
|
|
|
2019-05-04 05:25:00 +02:00
|
|
|
assert.False(t, c.Debug)
|
2019-05-04 09:11:33 +02:00
|
|
|
assert.False(t, c.ReadOnly)
|
2019-05-03 18:57:28 +02:00
|
|
|
assert.Equal(t, "/srv/photoprism", c.AssetsPath)
|
|
|
|
assert.Equal(t, "/srv/photoprism/cache", c.CachePath)
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/originals", c.OriginalsPath)
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/import", c.ImportPath)
|
|
|
|
assert.Equal(t, "/srv/photoprism/photos/export", c.ExportPath)
|
|
|
|
assert.Equal(t, "internal", c.DatabaseDriver)
|
|
|
|
assert.Equal(t, "root:photoprism@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn)
|
2019-05-04 05:25:00 +02:00
|
|
|
assert.Equal(t, 81, c.HttpServerPort)
|
2018-11-17 06:21:39 +01:00
|
|
|
}
|