Add failing tests for the format auto

Tests for #88, before the change:
the format chosen for each Accept header (AVIF-capable, WebP-only,
neither, wildcard only, absent, q=0 on AVIF, malformed), both image
routes serving an auto URL in the chosen format with Vary: Accept, also
on HEAD and 304, the signature covering auto rather than the chosen
format, each chosen format cached apart, and Vary: Accept next to the
CORS middleware's Vary: Origin. They do not compile yet: FormatAuto and
formatForAccept do not exist.

Model: opus-5-5
This commit is contained in:
2026-10-05 02:42:58 +00:00
parent 01823d27db
commit 39a647b6c5
3 changed files with 371 additions and 0 deletions
@@ -111,6 +111,21 @@ func TestParseImageURL(t *testing.T) {
}
}
// TestParseImageURL_AutoFormat verifies that the format auto in an image URL
// parses as FormatAuto.
func TestParseImageURL_AutoFormat(t *testing.T) {
t.Parallel()
got, err := ParseImageURL("/v1/image/example.com/photo.jpg/200x200.auto")
if err != nil {
t.Fatalf("ParseImageURL() error = %v", err)
}
if got.Format != FormatAuto {
t.Errorf("Format = %q, want %q", got.Format, FormatAuto)
}
}
func TestParseImageURL_Errors(t *testing.T) {
t.Parallel()