package prediction import "testing" func TestImageFilenameFromURLStripsQuery(t *testing.T) { png := []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A} got := imageFilenameFromURL("https://gateway.example.com/files/abc-123?exp=1&sig=deadbeef", png) if got != "abc-123.png" { t.Fatalf("got %q", got) } } func TestImageFilenameFromURLAddsExtension(t *testing.T) { jpg := []byte{0xFF, 0xD8, 0xFF, 0x00} got := imageFilenameFromURL("https://example.com/uploads/photo", jpg) if got != "photo.jpg" { t.Fatalf("got %q", got) } } func TestParseGatewayFileID(t *testing.T) { id, ok := parseGatewayFileID("http://localhost:8293/files/img-uuid?exp=1&sig=x") if !ok || id != "img-uuid" { t.Fatalf("got id=%q ok=%v", id, ok) } } func TestValidateImageBytes(t *testing.T) { if err := validateImageBytes(nil); err == nil { t.Fatal("expected empty payload error") } png := []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A} if err := validateImageBytes(png); err != nil { t.Fatal(err) } }