photoprism/internal/thumb/open_jpeg_test.go
Michael Mayer 2125f1ae0a JPEG: Call Seek(0, 0) before opening image #2462 #2463
Found this here, although I'm really not sure how this should fix it:
- https://github.com/golang/go/issues/45902#issuecomment-1007953723

According to the tests I added, the error "unexpected EOF" remains!
At least this change shouldn't break anything either.... Help is more
than welcome if someone has more time to read through all the issue
comments.
2022-06-25 02:16:42 +02:00

36 lines
656 B
Go

package thumb
import (
"testing"
)
func TestOpenJpeg(t *testing.T) {
t.Run("testdata/example.jpg", func(t *testing.T) {
img, err := OpenJpeg("testdata/example.jpg", 0)
if err != nil {
t.Fatal(err)
}
if img == nil {
t.Error("img must not be nil")
}
})
t.Run("testdata/broken.jpg", func(t *testing.T) {
if _, err := OpenJpeg("testdata/broken.jpg", 0); err == nil {
t.Error("unexpected EOF while decoding error expected")
}
})
t.Run("testdata/fixed.jpg", func(t *testing.T) {
img, err := OpenJpeg("testdata/fixed.jpg", 0)
if err != nil {
t.Fatal(err)
}
if img == nil {
t.Error("img must not be nil")
}
})
}