check / check (push) Canceled after 0s
internal/app now provides the cache, the fetcher, the processor, the image service, the session manager and the encrypted URL generator, and handlers.New receives them built. database.New opens the database, so these parts can read it while fx builds them; the cache's stop hook still runs before the database's. Each setting's default is declared in internal/config, the default cache_max_bytes included, which internal/app works out before it builds the cache. The cache's MaxBytes is the one value for the disk cache limit, and 0 turns the disk cache off. The fetcher and the processor take explicit values. The server tests build the pipeline themselves, as they cannot import internal/app. Model: opus-5-5
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package imageprocessor
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/davidbyttow/govips/v2/vips"
|
|
"sneak.berlin/go/pixa/internal/imagerequest"
|
|
)
|
|
|
|
// 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{
|
|
MaxInputBytes: 50 << 20,
|
|
MaxConcurrentProcessing: 1,
|
|
}).Process(
|
|
t.Context(), bytes.NewReader(tiff),
|
|
&imagerequest.Transform{Format: imagerequest.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)
|
|
}
|
|
}
|