photoprism/internal/config/config_resample_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

83 lines
2.5 KiB
Go

package config
import (
"testing"
"github.com/photoprism/photoprism/internal/thumb"
"github.com/stretchr/testify/assert"
)
func TestConfig_ConvertSize(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, 720, c.JpegSize())
c.options.JpegSize = 31000
assert.Equal(t, 30000, c.JpegSize())
c.options.JpegSize = 800
assert.Equal(t, 800, c.JpegSize())
}
func TestConfig_JpegQuality(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, thumb.QualityDefault, c.JpegQuality())
c.options.JpegQuality = "110"
assert.Equal(t, thumb.QualityDefault, c.JpegQuality())
c.options.JpegQuality = "98"
assert.Equal(t, thumb.Quality(98), c.JpegQuality())
c.options.JpegQuality = ""
assert.Equal(t, thumb.QualityDefault, c.JpegQuality())
c.options.JpegQuality = "best "
assert.Equal(t, thumb.QualityBest, c.JpegQuality())
c.options.JpegQuality = "high"
assert.Equal(t, thumb.QualityHigh, c.JpegQuality())
c.options.JpegQuality = "medium "
assert.Equal(t, thumb.QualityDefault, c.JpegQuality())
c.options.JpegQuality = "low "
assert.Equal(t, thumb.QualityLow, c.JpegQuality())
c.options.JpegQuality = "bad"
assert.Equal(t, thumb.QualityBad, c.JpegQuality())
c.options.JpegQuality = "worst "
assert.Equal(t, thumb.QualityWorst, c.JpegQuality())
c.options.JpegQuality = "default"
assert.Equal(t, thumb.QualityDefault, c.JpegQuality())
}
func TestConfig_ThumbFilter(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, thumb.ResampleFilter("cubic"), c.ThumbFilter())
c.options.ThumbFilter = "blackman"
assert.Equal(t, thumb.ResampleFilter("blackman"), c.ThumbFilter())
c.options.ThumbFilter = "lanczos"
assert.Equal(t, thumb.ResampleFilter("lanczos"), c.ThumbFilter())
c.options.ThumbFilter = "linear"
assert.Equal(t, thumb.ResampleFilter("linear"), c.ThumbFilter())
c.options.ThumbFilter = "cubic"
assert.Equal(t, thumb.ResampleFilter("cubic"), c.ThumbFilter())
}
func TestConfig_ThumbSizeUncached(t *testing.T) {
c := NewConfig(CliTestContext())
assert.False(t, c.ThumbUncached())
}
func TestConfig_ThumbSize(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, int(720), c.ThumbSizePrecached())
c.options.ThumbSize = 7681
assert.Equal(t, int(7680), c.ThumbSizePrecached())
}
func TestConfig_ThumbSizeUncached2(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, int(720), c.ThumbSizeUncached())
c.options.ThumbSizeUncached = 7681
assert.Equal(t, int(7680), c.ThumbSizeUncached())
c.options.ThumbSizeUncached = 800
c.options.ThumbSize = 900
assert.Equal(t, int(900), c.ThumbSizeUncached())
}