Files
Luminary/internal/prediction/params_test.go
T
renjue a4274be444
CI / docker (push) Successful in 4m52s
Split ingress keys into text/image protocols with Replicate model listing.
Text keys use OpenAI routes; image keys use predictions with ingress Model ID,
owner/name or short name resolution, OpenAPI input schemas, editable workflows
with per-field defaults, protocol-aware admin whitelist, and in-app API docs.

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

53 lines
1.5 KiB
Go

package prediction
import (
"testing"
"github.com/rose_cat707/luminary/internal/model"
)
func TestOpenAPISchemaForWorkflowTxt2Img(t *testing.T) {
schema := OpenAPISchemaForWorkflow(model.WorkflowTxt2Img, "flux", "FLUX txt2img", nil)
components, ok := schema["components"].(map[string]any)
if !ok {
t.Fatal("missing components")
}
schemas, ok := components["schemas"].(map[string]any)
if !ok {
t.Fatal("missing schemas")
}
input, ok := schemas["Input"].(map[string]any)
if !ok {
t.Fatal("missing Input schema")
}
props, ok := input["properties"].(map[string]any)
if !ok {
t.Fatal("missing properties")
}
if _, ok := props["prompt"]; !ok {
t.Fatal("missing prompt property")
}
if _, ok := props["image"]; ok {
t.Fatal("txt2img should not expose image input")
}
required, ok := input["required"].([]string)
if !ok || len(required) == 0 || required[0] != "prompt" {
t.Fatalf("unexpected required: %#v", input["required"])
}
}
func TestOpenAPISchemaForWorkflowImg2Img(t *testing.T) {
schema := OpenAPISchemaForWorkflow(model.WorkflowImg2Img, "flux-i2i", "FLUX img2img", nil)
components := schema["components"].(map[string]any)
schemas := components["schemas"].(map[string]any)
input := schemas["Input"].(map[string]any)
props := input["properties"].(map[string]any)
if _, ok := props["image"]; !ok {
t.Fatal("missing image property")
}
required := input["required"].([]string)
if len(required) != 2 {
t.Fatalf("expected prompt and image required, got %#v", required)
}
}