mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-03-22 20:21:28 +02:00
39 lines
604 B
Go
39 lines
604 B
Go
package bimg
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRead(t *testing.T) {
|
|
buf, err := Read("fixtures/test.jpg")
|
|
|
|
if err != nil {
|
|
t.Errorf("Cannot read the image: %#v", err)
|
|
}
|
|
|
|
if len(buf) == 0 {
|
|
t.Fatal("Empty buffer")
|
|
}
|
|
|
|
if DetermineImageType(buf) != JPEG {
|
|
t.Fatal("Image is not jpeg")
|
|
}
|
|
}
|
|
|
|
func TestWrite(t *testing.T) {
|
|
buf, err := Read("fixtures/test.jpg")
|
|
|
|
if err != nil {
|
|
t.Errorf("Cannot read the image: %#v", err)
|
|
}
|
|
|
|
if len(buf) == 0 {
|
|
t.Fatal("Empty buffer")
|
|
}
|
|
|
|
err = Write("fixtures/test_write_out.jpg", buf)
|
|
if err != nil {
|
|
t.Fatalf("Cannot write the file: %#v", err)
|
|
}
|
|
}
|