photoprism/internal/config/config_ui_test.go
Michael Mayer 92e6c4fe1e Download: Add Disabled, Originals, MediaRaw & MediaSidecar Flags #2234
Extends DownloadSettings with 4 additional options:
- Name: File name pattern for downloaded files (existed)
- Disabled: Disables downloads
- Originals: Only download files stored in "originals" folder
- MediaRaw: Include RAW image files
- MediaSidecar: Include metadata sidecar files (JSON, XMP, YAML)
2022-04-15 09:42:07 +02:00

79 lines
2.1 KiB
Go

package config
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig_DefaultTheme(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "default", c.DefaultTheme())
c.options.Sponsor = false
c.options.DefaultTheme = "grayscale"
assert.Equal(t, "default", c.DefaultTheme())
c.options.Sponsor = true
assert.Equal(t, "grayscale", c.DefaultTheme())
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())
}
func TestConfig_AppIcon(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "logo", c.AppIcon())
c.options.AppIcon = "foo"
assert.Equal(t, "logo", c.AppIcon())
c.options.AppIcon = "app"
assert.Equal(t, "app", c.AppIcon())
c.options.AppIcon = "crisp"
assert.Equal(t, "crisp", c.AppIcon())
c.options.AppIcon = "mint"
assert.Equal(t, "mint", c.AppIcon())
c.options.AppIcon = "bold"
assert.Equal(t, "bold", c.AppIcon())
c.options.AppIcon = "logo"
assert.Equal(t, "logo", c.AppIcon())
}
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")
}
if p := c.AppIconsPath("app"); !strings.HasSuffix(p, "photoprism/assets/static/icons/app") {
t.Fatal("path .../pphotoprism/assets/static/icons/app expected")
}
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")
}
}
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())
}