diff --git a/internal/config/client_test.go b/internal/config/client_test.go index 445698740..ac7534439 100644 --- a/internal/config/client_test.go +++ b/internal/config/client_test.go @@ -22,3 +22,12 @@ func TestConfig_GuestConfig(t *testing.T) { assert.IsType(t, ClientConfig{}, result) assert.Equal(t, true, result.Public) } + +func TestConfig_Flags(t *testing.T) { + config := NewTestConfig() + config.params.Experimental = true + config.params.ReadOnly = true + + result := config.Flags() + assert.Equal(t, []string{"public", "debug", "experimental", "readonly", "settings"}, result) +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 6ea459b29..9cc7096b2 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -337,9 +337,38 @@ func TestConfig_WakeupInterval(t *testing.T) { func TestConfig_GeoCodingApi(t *testing.T) { c := NewTestConfig() assert.Equal(t, "", c.GeoCodingApi()) + c.params.GeoCodingApi = "places" + assert.Equal(t, "places", c.GeoCodingApi()) + c.params.GeoCodingApi = "osm" + assert.Equal(t, "osm", c.GeoCodingApi()) } func TestConfig_OriginalsLimit(t *testing.T) { c := NewTestConfig() assert.Equal(t, int64(-1), c.OriginalsLimit()) + c.params.OriginalsLimit = 800 + assert.Equal(t, int64(838860800), c.OriginalsLimit()) +} + +func TestConfig_SiteUrl(t *testing.T) { + c := NewTestConfig() + assert.Equal(t, "http://localhost:2342/", c.SiteUrl()) + c.params.SiteUrl = "http://superhost:2342/" + assert.Equal(t, "http://superhost:2342/", c.SiteUrl()) +} + +func TestConfig_SitePreview(t *testing.T) { + c := NewTestConfig() + assert.Equal(t, "http://localhost:2342/static/img/preview.jpg", c.SitePreview()) + c.params.SitePreview = "http://preview.jpg" + assert.Equal(t, "http://preview.jpg", c.SitePreview()) + c.params.SitePreview = "preview123.jpg" + assert.Equal(t, "http://localhost:2342/preview123.jpg", c.SitePreview()) +} + +func TestConfig_SiteTitle(t *testing.T) { + c := NewTestConfig() + assert.Equal(t, "PhotoPrism", c.SiteTitle()) + c.params.SiteTitle = "Cats" + assert.Equal(t, "Cats", c.SiteTitle()) } diff --git a/internal/config/resample_test.go b/internal/config/resample_test.go index e21fe1567..090847237 100644 --- a/internal/config/resample_test.go +++ b/internal/config/resample_test.go @@ -33,6 +33,8 @@ func TestConfig_ThumbFilter(t *testing.T) { assert.Equal(t, thumb.ResampleFilter("lanczos"), c.ThumbFilter()) c.params.ThumbFilter = "linear" assert.Equal(t, thumb.ResampleFilter("linear"), c.ThumbFilter()) + c.params.ThumbFilter = "cubic" + assert.Equal(t, thumb.ResampleFilter("cubic"), c.ThumbFilter()) } func TestConfig_ThumbSizeUncached(t *testing.T) { @@ -54,5 +56,5 @@ func TestConfig_ThumbSizeUncached2(t *testing.T) { assert.Equal(t, int(7680), c.ThumbSizeUncached()) c.params.ThumbSizeUncached = 800 c.params.ThumbSize = 900 - assert.Equal(t, int(900), c.ThumbSize()) + assert.Equal(t, int(900), c.ThumbSizeUncached()) } diff --git a/internal/config/server_test.go b/internal/config/server_test.go index f0f2c798b..c21b424eb 100644 --- a/internal/config/server_test.go +++ b/internal/config/server_test.go @@ -24,6 +24,8 @@ func TestConfig_HttpServerMode2(t *testing.T) { assert.Equal(t, "debug", c.HttpServerMode()) c.params.Debug = false assert.Equal(t, "release", c.HttpServerMode()) + c.params.HttpServerMode = "test" + assert.Equal(t, "test", c.HttpServerMode()) } func TestConfig_TemplateName(t *testing.T) { @@ -31,4 +33,7 @@ func TestConfig_TemplateName(t *testing.T) { assert.Equal(t, "index.tmpl", c.TemplateName()) c.settings.Templates.Default = "rainbow.tmpl" assert.Equal(t, "rainbow.tmpl", c.TemplateName()) + c.settings.Templates.Default = "xxx" + assert.Equal(t, "index.tmpl", c.TemplateName()) + }