Add failing test for AVIF encoding
Test verifies that images can be encoded to AVIF format. Currently fails because AVIF encoding is not implemented. Removes the rejection test for AVIF output format.
This commit is contained in:
@@ -3,7 +3,6 @@ package imgcache
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/jpeg"
|
||||
@@ -457,7 +456,7 @@ func TestImageProcessor_DecodeAVIF(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageProcessor_RejectsUnsupportedOutputFormat_AVIF(t *testing.T) {
|
||||
func TestImageProcessor_EncodeAVIF(t *testing.T) {
|
||||
proc := NewImageProcessor()
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -470,12 +469,32 @@ func TestImageProcessor_RejectsUnsupportedOutputFormat_AVIF(t *testing.T) {
|
||||
FitMode: FitCover,
|
||||
}
|
||||
|
||||
_, err := proc.Process(ctx, bytes.NewReader(input), req)
|
||||
if err == nil {
|
||||
t.Fatal("Process() should return error for unsupported AVIF encoding")
|
||||
result, err := proc.Process(ctx, bytes.NewReader(input), req)
|
||||
if err != nil {
|
||||
t.Fatalf("Process() error = %v, want nil (AVIF encoding should work)", err)
|
||||
}
|
||||
defer result.Content.Close()
|
||||
|
||||
// Verify output is valid AVIF
|
||||
data, err := io.ReadAll(result.Content)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read result: %v", err)
|
||||
}
|
||||
|
||||
if !errors.Is(err, ErrUnsupportedOutputFormat) {
|
||||
t.Errorf("Process() error = %v, want ErrUnsupportedOutputFormat", err)
|
||||
mime, err := DetectFormat(data)
|
||||
if err != nil {
|
||||
t.Fatalf("DetectFormat() error = %v", err)
|
||||
}
|
||||
|
||||
if mime != MIMETypeAVIF {
|
||||
t.Errorf("Output format = %v, want %v", mime, MIMETypeAVIF)
|
||||
}
|
||||
|
||||
// Verify dimensions
|
||||
if result.Width != 100 {
|
||||
t.Errorf("Width = %d, want 100", result.Width)
|
||||
}
|
||||
if result.Height != 75 {
|
||||
t.Errorf("Height = %d, want 75", result.Height)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user