Add failing test for WebP encoding support

TDD: This test expects WebP encoding to succeed. It currently fails
because WebP encoding is not implemented (returns ErrUnsupportedOutputFormat).
The test will pass once we add the gen2brain/webp library.
This commit is contained in:
Jeffrey Paul 2026-01-08 11:54:03 -08:00
parent aab43db44a
commit 0c9eb35bd2

View File

@ -313,7 +313,7 @@ func TestImageProcessor_AcceptsMaxDimensionInput(t *testing.T) {
defer result.Content.Close()
}
func TestImageProcessor_RejectsUnsupportedOutputFormat_WebP(t *testing.T) {
func TestImageProcessor_EncodeWebP(t *testing.T) {
proc := NewImageProcessor()
ctx := context.Background()
@ -322,17 +322,37 @@ func TestImageProcessor_RejectsUnsupportedOutputFormat_WebP(t *testing.T) {
req := &ImageRequest{
Size: Size{Width: 100, Height: 75},
Format: FormatWebP,
Quality: 85,
Quality: 80,
FitMode: FitCover,
}
_, err := proc.Process(ctx, bytes.NewReader(input), req)
if err == nil {
t.Fatal("Process() should return error for unsupported WebP encoding")
result, err := proc.Process(ctx, bytes.NewReader(input), req)
if err != nil {
t.Fatalf("Process() error = %v, want nil", err)
}
defer result.Content.Close()
// Verify output is valid WebP
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 != MIMETypeWebP {
t.Errorf("Output format = %v, want %v", mime, MIMETypeWebP)
}
// 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)
}
}