diff --git a/internal/imgcache/processor_test.go b/internal/imgcache/processor_test.go index b0b6135..209b141 100644 --- a/internal/imgcache/processor_test.go +++ b/internal/imgcache/processor_test.go @@ -196,6 +196,66 @@ func TestImageProcessor_FitContain(t *testing.T) { } } +func TestImageProcessor_ProportionalScale_WidthOnly(t *testing.T) { + proc := NewImageProcessor() + ctx := context.Background() + + // 800x600 image, request width=400 height=0 + // Should scale proportionally to 400x300 + input := createTestJPEG(t, 800, 600) + + req := &ImageRequest{ + Size: Size{Width: 400, Height: 0}, + Format: FormatJPEG, + Quality: 85, + FitMode: FitCover, + } + + result, err := proc.Process(ctx, bytes.NewReader(input), req) + if err != nil { + t.Fatalf("Process() error = %v", err) + } + defer result.Content.Close() + + if result.Width != 400 { + t.Errorf("Process() width = %d, want 400", result.Width) + } + + if result.Height != 300 { + t.Errorf("Process() height = %d, want 300", result.Height) + } +} + +func TestImageProcessor_ProportionalScale_HeightOnly(t *testing.T) { + proc := NewImageProcessor() + ctx := context.Background() + + // 800x600 image, request width=0 height=300 + // Should scale proportionally to 400x300 + input := createTestJPEG(t, 800, 600) + + req := &ImageRequest{ + Size: Size{Width: 0, Height: 300}, + Format: FormatJPEG, + Quality: 85, + FitMode: FitCover, + } + + result, err := proc.Process(ctx, bytes.NewReader(input), req) + if err != nil { + t.Fatalf("Process() error = %v", err) + } + defer result.Content.Close() + + if result.Width != 400 { + t.Errorf("Process() width = %d, want 400", result.Width) + } + + if result.Height != 300 { + t.Errorf("Process() height = %d, want 300", result.Height) + } +} + func TestImageProcessor_ProcessPNG(t *testing.T) { proc := NewImageProcessor() ctx := context.Background()