diff --git a/internal/imgcache/processor_test.go b/internal/imgcache/processor_test.go index 135ca80..4a23d47 100644 --- a/internal/imgcache/processor_test.go +++ b/internal/imgcache/processor_test.go @@ -3,6 +3,7 @@ package imgcache import ( "bytes" "context" + "errors" "image" "image/color" "image/jpeg" @@ -311,3 +312,49 @@ func TestImageProcessor_AcceptsMaxDimensionInput(t *testing.T) { } defer result.Content.Close() } + +func TestImageProcessor_RejectsUnsupportedOutputFormat_WebP(t *testing.T) { + proc := NewImageProcessor() + ctx := context.Background() + + input := createTestJPEG(t, 200, 150) + + req := &ImageRequest{ + Size: Size{Width: 100, Height: 75}, + Format: FormatWebP, + Quality: 85, + FitMode: FitCover, + } + + _, err := proc.Process(ctx, bytes.NewReader(input), req) + if err == nil { + t.Fatal("Process() should return error for unsupported WebP encoding") + } + + if !errors.Is(err, ErrUnsupportedOutputFormat) { + t.Errorf("Process() error = %v, want ErrUnsupportedOutputFormat", err) + } +} + +func TestImageProcessor_RejectsUnsupportedOutputFormat_AVIF(t *testing.T) { + proc := NewImageProcessor() + ctx := context.Background() + + input := createTestJPEG(t, 200, 150) + + req := &ImageRequest{ + Size: Size{Width: 100, Height: 75}, + Format: FormatAVIF, + Quality: 85, + FitMode: FitCover, + } + + _, err := proc.Process(ctx, bytes.NewReader(input), req) + if err == nil { + t.Fatal("Process() should return error for unsupported AVIF encoding") + } + + if !errors.Is(err, ErrUnsupportedOutputFormat) { + t.Errorf("Process() error = %v, want ErrUnsupportedOutputFormat", err) + } +}