2021-11-25 17:24:53 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
func TestConfig_DefaultTheme(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "default", c.DefaultTheme())
|
2022-04-22 17:38:40 +02:00
|
|
|
c.options.Demo = false
|
2022-04-15 09:42:07 +02:00
|
|
|
c.options.Sponsor = false
|
2022-04-22 17:38:40 +02:00
|
|
|
c.options.Test = false
|
2022-04-15 09:42:07 +02:00
|
|
|
c.options.DefaultTheme = "grayscale"
|
|
|
|
assert.Equal(t, "default", c.DefaultTheme())
|
|
|
|
c.options.Sponsor = true
|
|
|
|
assert.Equal(t, "grayscale", c.DefaultTheme())
|
2022-04-22 17:38:40 +02:00
|
|
|
c.options.Sponsor = false
|
|
|
|
c.options.Test = true
|
|
|
|
assert.Equal(t, "grayscale", c.DefaultTheme())
|
|
|
|
c.options.Sponsor = false
|
|
|
|
c.options.Test = false
|
|
|
|
assert.Equal(t, "default", c.DefaultTheme())
|
|
|
|
c.options.Sponsor = true
|
2022-04-15 09:42:07 +02:00
|
|
|
c.options.DefaultTheme = ""
|
|
|
|
assert.Equal(t, "default", c.DefaultTheme())
|
|
|
|
c.options.Sponsor = false
|
|
|
|
assert.Equal(t, "default", c.DefaultTheme())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_DefaultLocale(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "en", c.DefaultLocale())
|
|
|
|
c.options.DefaultLocale = "de"
|
|
|
|
assert.Equal(t, "de", c.DefaultLocale())
|
|
|
|
c.options.DefaultLocale = ""
|
|
|
|
assert.Equal(t, "en", c.DefaultLocale())
|
|
|
|
}
|
|
|
|
|
2021-11-25 17:24:53 +01:00
|
|
|
func TestConfig_AppIcon(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
2021-11-29 18:12:35 +01:00
|
|
|
assert.Equal(t, "logo", c.AppIcon())
|
2021-11-25 17:24:53 +01:00
|
|
|
c.options.AppIcon = "foo"
|
2021-11-29 18:12:35 +01:00
|
|
|
assert.Equal(t, "logo", c.AppIcon())
|
2021-11-29 14:39:21 +01:00
|
|
|
c.options.AppIcon = "app"
|
|
|
|
assert.Equal(t, "app", c.AppIcon())
|
2021-11-29 18:12:35 +01:00
|
|
|
c.options.AppIcon = "crisp"
|
|
|
|
assert.Equal(t, "crisp", c.AppIcon())
|
2021-11-29 14:39:21 +01:00
|
|
|
c.options.AppIcon = "mint"
|
|
|
|
assert.Equal(t, "mint", c.AppIcon())
|
2021-11-29 14:57:58 +01:00
|
|
|
c.options.AppIcon = "bold"
|
|
|
|
assert.Equal(t, "bold", c.AppIcon())
|
2021-11-29 18:12:35 +01:00
|
|
|
c.options.AppIcon = "logo"
|
|
|
|
assert.Equal(t, "logo", c.AppIcon())
|
2021-11-25 17:24:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_AppIconsPath(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
if p := c.AppIconsPath(); !strings.HasSuffix(p, "photoprism/assets/static/icons") {
|
|
|
|
t.Fatal("path .../photoprism/assets/static/icons expected")
|
|
|
|
}
|
|
|
|
|
2021-11-29 14:39:21 +01:00
|
|
|
if p := c.AppIconsPath("app"); !strings.HasSuffix(p, "photoprism/assets/static/icons/app") {
|
|
|
|
t.Fatal("path .../pphotoprism/assets/static/icons/app expected")
|
2021-11-25 17:24:53 +01:00
|
|
|
}
|
|
|
|
|
2021-11-29 14:39:21 +01:00
|
|
|
if p := c.AppIconsPath("app", "512.png"); !strings.HasSuffix(p, "photoprism/assets/static/icons/app/512.png") {
|
|
|
|
t.Fatal("path .../photoprism/assets/static/icons/app/512.png expected")
|
2021-11-25 17:24:53 +01:00
|
|
|
}
|
|
|
|
}
|
2021-11-29 14:39:21 +01:00
|
|
|
|
|
|
|
func TestConfig_AppName(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "config.test", c.AppName())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig_AppMode(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "standalone", c.AppMode())
|
|
|
|
}
|
2022-04-22 17:38:40 +02:00
|
|
|
|
|
|
|
func TestConfig_WallpaperUri(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "", c.WallpaperUri())
|
|
|
|
c.options.WallpaperUri = "kashmir"
|
|
|
|
assert.Equal(t, "/static/img/wallpaper/kashmir.jpg", c.WallpaperUri())
|
|
|
|
c.options.WallpaperUri = "https://cdn.photoprism.app/wallpaper/welcome.jpg"
|
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
|
|
|
c.options.Test = false
|
|
|
|
assert.Equal(t, "", c.WallpaperUri())
|
|
|
|
c.options.Test = true
|
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
|
|
|
c.options.WallpaperUri = ""
|
|
|
|
assert.Equal(t, "", c.WallpaperUri())
|
|
|
|
}
|