photoprism/internal/thumb/thumb_test.go
Michael Mayer 5ec90a5fff Index: Skip redundant thumbs and support symbolic file links #1049 #1874
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-07-06 23:01:54 +02:00

48 lines
1.1 KiB
Go

package thumb
import (
"bytes"
"os"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
var logBuffer bytes.Buffer
func TestMain(m *testing.M) {
log = logrus.StandardLogger()
log.Out = &logBuffer
log.SetLevel(logrus.TraceLevel)
code := m.Run()
// remove temporary test files
_ = os.RemoveAll("testdata/1")
os.Exit(code)
}
func TestNew(t *testing.T) {
fileHash := "d2b4a5d18276f96f1b5a1bf17fd82d6fab3807f2"
contentUri := "/content"
previewToken := "preview-token"
t.Run("Fit1280", func(t *testing.T) {
result := New(1920, 1080, fileHash, Sizes[Fit1280], contentUri, previewToken)
assert.Equal(t, 1280, result.W)
assert.Equal(t, 720, result.H)
assert.Equal(t, "/content/t/d2b4a5d18276f96f1b5a1bf17fd82d6fab3807f2/preview-token/fit_1280", result.Src)
})
t.Run("Fit3840", func(t *testing.T) {
result := New(1920, 1080, fileHash, Sizes[Fit3840], contentUri, previewToken)
assert.Equal(t, 1920, result.W)
assert.Equal(t, 1080, result.H)
assert.Equal(t, "/content/t/d2b4a5d18276f96f1b5a1bf17fd82d6fab3807f2/preview-token/fit_3840", result.Src)
})
}