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:
2026-01-08 13:09:40 -08:00
parent 9bfae69ccf
commit 615586fcea
2 changed files with 41 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import (
"image/jpeg"
"image/png"
"io"
"os"
"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) {
proc := NewImageProcessor()
ctx := context.Background()

BIN
internal/imgcache/testdata/red.avif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B