Add failing test for AVIF decoding
Test verifies that AVIF images can be decoded and processed. Currently fails because AVIF decoding is not implemented.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -416,6 +417,46 @@ func TestImageProcessor_EncodeWebP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImageProcessor_DecodeAVIF(t *testing.T) {
|
||||||
|
proc := NewImageProcessor()
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// Load test AVIF file
|
||||||
|
input, err := os.ReadFile("testdata/red.avif")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to read test AVIF: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request resize and convert to JPEG
|
||||||
|
req := &ImageRequest{
|
||||||
|
Size: Size{Width: 2, Height: 2},
|
||||||
|
Format: FormatJPEG,
|
||||||
|
Quality: 85,
|
||||||
|
FitMode: FitCover,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := proc.Process(ctx, bytes.NewReader(input), req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Process() error = %v, want nil (AVIF decoding should work)", err)
|
||||||
|
}
|
||||||
|
defer result.Content.Close()
|
||||||
|
|
||||||
|
// Verify output is valid JPEG
|
||||||
|
data, err := io.ReadAll(result.Content)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to read result: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mime, err := DetectFormat(data)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("DetectFormat() error = %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if mime != MIMETypeJPEG {
|
||||||
|
t.Errorf("Output format = %v, want %v", mime, MIMETypeJPEG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestImageProcessor_RejectsUnsupportedOutputFormat_AVIF(t *testing.T) {
|
func TestImageProcessor_RejectsUnsupportedOutputFormat_AVIF(t *testing.T) {
|
||||||
proc := NewImageProcessor()
|
proc := NewImageProcessor()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
BIN
internal/imgcache/testdata/red.avif
vendored
Normal file
BIN
internal/imgcache/testdata/red.avif
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 281 B |
Reference in New Issue
Block a user