check / check (push) Waiting to run
README.md, the doc comment of ErrUnsupportedInputFormat and the TODO.md entry say the 415 is for input whose first bytes libvips reads as another format, and no longer read as refusing a damaged image in a source format, which is decoded and answers 500. The doc comment of TestImageProcessor_OrigOfUnnamedFormatRefused says TIFF is refused before it is decoded. Model: opus-5-5
40 lines
1005 B
Go
40 lines
1005 B
Go
package imageprocessor
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/davidbyttow/govips/v2/vips"
|
|
)
|
|
|
|
// TestImageProcessor_OrigOfUnnamedFormatRefused verifies that orig of a TIFF
|
|
// input, which is not a source format, is refused with
|
|
// ErrUnsupportedInputFormat before it is decoded, and not saved as JPEG.
|
|
func TestImageProcessor_OrigOfUnnamedFormatRefused(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
img, err := vips.NewImageFromBuffer(createTestPNG(t, 20, 20))
|
|
if err != nil {
|
|
t.Fatalf("failed to decode test PNG: %v", err)
|
|
}
|
|
|
|
t.Cleanup(img.Close)
|
|
|
|
tiff, _, err := img.ExportTiff(vips.NewTiffExportParams())
|
|
if err != nil {
|
|
t.Fatalf("failed to save test TIFF: %v", err)
|
|
}
|
|
|
|
result, err := New(Params{}).Process(
|
|
t.Context(), bytes.NewReader(tiff), &Request{Format: FormatOriginal},
|
|
)
|
|
if result != nil {
|
|
t.Logf("Process() returned %s", result.ContentType)
|
|
}
|
|
|
|
if !errors.Is(err, ErrUnsupportedInputFormat) {
|
|
t.Errorf("Process() error = %v, want %v", err, ErrUnsupportedInputFormat)
|
|
}
|
|
}
|