Files
renjue 321683f863
CI / docker (push) Successful in 3m38s
Split ingress keys into text/image protocols with Replicate model listing.
Add model input defaults (including prompt), workflow model editing, ingress API docs, and fix img2img image upload filenames for signed URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:49:06 +08:00

37 lines
1011 B
Go

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)
}
}