photoprism/internal/thumb/memsize_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

27 lines
478 B
Go

package thumb
import (
"testing"
"github.com/disintegration/imaging"
"github.com/stretchr/testify/assert"
)
func TestMemSize(t *testing.T) {
src := "testdata/example.jpg"
assert.FileExists(t, src)
img, err := imaging.Open(src, imaging.AutoOrientation(true))
if err != nil {
t.Fatal(err)
}
result := MemSize(img)
assert.InEpsilon(t, 1464, result.KByte(), 1)
assert.InEpsilon(t, 1.430511474, result.MByte(), 0.1)
assert.Equal(t, "1.5 MB", result.String())
}