diff --git a/internal/imgcache/processor_test.go b/internal/imgcache/processor_test.go index 50fa026..c4a036b 100644 --- a/internal/imgcache/processor_test.go +++ b/internal/imgcache/processor_test.go @@ -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) } }