check / check (push) Canceled after 0s
The new package internal/providers builds the cache, the fetcher, the processor, the image service, the session manager and the encrypted URL generator from the config. pixad's fx graph provides them with providers.Constructors(), and handlers.New receives them built. The server tests build the same graph, with only the fetcher's dial function replaced. 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, and internal/providers works out the default cache_max_bytes. 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. Model: opus-5-5
31 lines
731 B
Go
31 lines
731 B
Go
package httpfetcher
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestJPEGXLContentType verifies that the fetcher accepts an upstream answer
|
|
// of type image/jxl, and that the mock fetcher serves a .jxl file as
|
|
// image/jxl.
|
|
func TestJPEGXLContentType(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const jxlType = "image/jxl"
|
|
|
|
f := New(&Config{
|
|
Timeout: 30 * time.Second,
|
|
MaxResponseSize: 50 << 20,
|
|
MaxConnectionsPerHost: 20,
|
|
MaxConnections: 64,
|
|
})
|
|
|
|
if !f.isAllowedContentType(jxlType) {
|
|
t.Errorf("isAllowedContentType(%q) = false, want true", jxlType)
|
|
}
|
|
|
|
if got := detectContentTypeFromPath("images/photo.jxl"); got != jxlType {
|
|
t.Errorf("detectContentTypeFromPath(photo.jxl) = %q, want %q", got, jxlType)
|
|
}
|
|
}
|