2021-11-25 17:24:53 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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"
|
2023-05-13 16:02:49 +02:00
|
|
|
assert.Equal(t, "grayscale", c.DefaultTheme())
|
2022-04-15 09:42:07 +02:00
|
|
|
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
|
2023-05-13 16:02:49 +02:00
|
|
|
assert.Equal(t, "grayscale", c.DefaultTheme())
|
2022-04-22 17:38:40 +02:00
|
|
|
c.options.Sponsor = false
|
|
|
|
c.options.Test = false
|
2023-05-13 16:02:49 +02:00
|
|
|
assert.Equal(t, "grayscale", c.DefaultTheme())
|
2022-04-22 17:38:40 +02:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:38:40 +02:00
|
|
|
func TestConfig_WallpaperUri(t *testing.T) {
|
|
|
|
c := NewConfig(CliTestContext())
|
|
|
|
|
|
|
|
assert.Equal(t, "", c.WallpaperUri())
|
2023-03-20 10:28:01 +01:00
|
|
|
assert.Equal(t, "", c.Options().WallpaperUri)
|
|
|
|
c.SetWallpaperUri("kashmir")
|
2022-04-22 17:38:40 +02:00
|
|
|
assert.Equal(t, "/static/img/wallpaper/kashmir.jpg", c.WallpaperUri())
|
2023-03-20 10:28:01 +01:00
|
|
|
c.SetWallpaperUri("https://cdn.photoprism.app/wallpaper/welcome.jpg")
|
2022-04-22 17:38:40 +02:00
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
|
|
|
c.options.Test = false
|
2022-07-05 23:13:34 +02:00
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
2022-04-22 17:38:40 +02:00
|
|
|
c.options.Test = true
|
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
2022-07-05 23:13:34 +02:00
|
|
|
c.options.Sponsor = false
|
2023-03-02 16:52:05 +01:00
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
2022-07-05 23:13:34 +02:00
|
|
|
c.options.Sponsor = true
|
|
|
|
assert.Equal(t, "https://cdn.photoprism.app/wallpaper/welcome.jpg", c.WallpaperUri())
|
2023-03-20 10:28:01 +01:00
|
|
|
c.SetWallpaperUri("kashmir")
|
2022-07-05 23:13:34 +02:00
|
|
|
assert.Equal(t, "/static/img/wallpaper/kashmir.jpg", c.WallpaperUri())
|
2023-03-20 10:28:01 +01:00
|
|
|
c.SetWallpaperUri("kashmir")
|
|
|
|
c.options.CdnUrl = "https://bunny.net/cdn/"
|
|
|
|
assert.Equal(t, "https://bunny.net/cdn/static/img/wallpaper/kashmir.jpg", c.WallpaperUri())
|
|
|
|
assert.Equal(t, "kashmir", c.Options().WallpaperUri)
|
|
|
|
c.SetWallpaperUri("kashmir")
|
|
|
|
c.options.CdnUrl = ""
|
|
|
|
assert.Equal(t, "/static/img/wallpaper/kashmir.jpg", c.WallpaperUri())
|
|
|
|
c.SetWallpaperUri("")
|
2022-04-22 17:38:40 +02:00
|
|
|
assert.Equal(t, "", c.WallpaperUri())
|
2023-03-20 10:28:01 +01:00
|
|
|
assert.Equal(t, "", c.Options().WallpaperUri)
|
2022-04-22 17:38:40 +02:00
|
|
|
}
|