Files
Atlas/internal/provider/model_schema_test.go
T
renjue 16b05476a1
CI / docker (push) Failing after 1m54s
实现 Atlas AI 平台一期能力并完成品牌化改造。
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:47:33 +08:00

47 lines
1.3 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 models[0].ModelName != "qwen-image-edit" {
t.Fatalf("edit model name: %s", models[0].ModelName)
}
if models[0].PredictionVersion() != "comfyui/qwen-image-edit" {
t.Fatalf("edit prediction version: %s", models[0].PredictionVersion())
}
}
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")
}
}