5301557ad2
CI / docker (push) Has been cancelled
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。 Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseReplicateModelDetails(t *testing.T) {
|
|
body, err := os.ReadFile("testdata/models_sample.json")
|
|
if err != nil {
|
|
t.Skip("sample file missing")
|
|
}
|
|
models := parseReplicateModelDetails(body)
|
|
if len(models) != 2 {
|
|
t.Fatalf("expected 2 models, got %d", len(models))
|
|
}
|
|
if models[0].Kind != ModelKindImageToImage {
|
|
t.Fatalf("edit model kind: %s", models[0].Kind)
|
|
}
|
|
if models[1].Kind != ModelKindTextToImage {
|
|
t.Fatalf("text model kind: %s", models[1].Kind)
|
|
}
|
|
if len(models[0].InputSchema) < 3 {
|
|
t.Fatalf("expected schema fields")
|
|
}
|
|
}
|
|
|
|
func TestInferModelKind(t *testing.T) {
|
|
schema := []InputField{{Name: "prompt", Required: true}, {Name: "image", Required: true, Widget: "image"}}
|
|
if inferModelKind(schema) != ModelKindImageToImage {
|
|
t.Fatal("expected image_to_image")
|
|
}
|
|
}
|
|
|
|
func TestValidateModelInput(t *testing.T) {
|
|
schema := []InputField{{Name: "prompt", Required: true}}
|
|
if err := ValidateModelInput(schema, map[string]any{"prompt": "hi"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := ValidateModelInput(schema, map[string]any{}); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|