1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00
imgproxy/imagemeta/jpeg_test.go
2024-04-18 21:16:32 +03:00

53 lines
878 B
Go

package imagemeta
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/suite"
"github.com/imgproxy/imgproxy/v3/imagetype"
)
type JpegTestSuite struct {
suite.Suite
}
func (s *JpegTestSuite) openFile(name string) *os.File {
wd, err := os.Getwd()
s.Require().NoError(err)
path := filepath.Join(wd, "..", "testdata", name)
f, err := os.Open(path)
s.Require().NoError(err)
return f
}
func (s *JpegTestSuite) TestDecodeJpegMeta() {
files := []string{
"test1.jpg",
"test1.arith.jpg",
}
expectedMeta := &meta{
format: imagetype.JPEG,
width: 10,
height: 10,
}
for _, file := range files {
func() {
f := s.openFile(file)
defer f.Close()
metadata, err := DecodeJpegMeta(f)
s.Require().NoError(err)
s.Require().Equal(expectedMeta, metadata)
}()
}
}
func TestJpeg(t *testing.T) {
suite.Run(t, new(JpegTestSuite))
}