2019-05-06 23:18:10 +02:00
|
|
|
package config
|
2018-11-17 06:21:39 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-01-12 14:00:56 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
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
|
|
|
|
2020-01-31 15:29:06 +01:00
|
|
|
assert.Equal(t, fs.Abs("../../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
|
|
|
|
2020-03-28 21:44:30 +01:00
|
|
|
err := c.Load("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)
|
2020-04-06 23:04:52 +02:00
|
|
|
assert.Equal(t, "/srv/photoprism/temp", c.TempPath)
|
2020-05-30 14:52:47 +02:00
|
|
|
assert.NotEmpty(t, c.DatabaseDriver)
|
|
|
|
assert.NotEmpty(t, c.DatabaseDsn)
|
2019-05-04 05:25:00 +02:00
|
|
|
assert.Equal(t, 81, c.HttpServerPort)
|
2018-11-17 06:21:39 +01:00
|
|
|
}
|