4bc1b8d2e3
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>
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestValidateProviderBinding(t *testing.T) {
|
|
cases := []struct {
|
|
protocol string
|
|
serviceType string
|
|
ok bool
|
|
}{
|
|
{"openai", "chat", true},
|
|
{"replicate", "image_generation", true},
|
|
{"replicate", "text_to_image", true},
|
|
{"replicate", "image_to_image", true},
|
|
{"openai", "text_to_image", false},
|
|
{"replicate", "chat", false},
|
|
{"unknown", "chat", false},
|
|
}
|
|
for _, tc := range cases {
|
|
err := ValidateProviderBinding(tc.protocol, tc.serviceType)
|
|
if tc.ok && err != nil {
|
|
t.Fatalf("%s/%s expected ok, got %v", tc.protocol, tc.serviceType, err)
|
|
}
|
|
if !tc.ok && err == nil {
|
|
t.Fatalf("%s/%s expected error", tc.protocol, tc.serviceType)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDefaultBindings(t *testing.T) {
|
|
if got := DefaultProtocol(ServiceImageGeneration); got != "replicate" {
|
|
t.Fatalf("expected replicate, got %s", got)
|
|
}
|
|
if got := DefaultServiceType("openai"); got != ServiceChat {
|
|
t.Fatalf("expected chat, got %s", got)
|
|
}
|
|
if got := DefaultServiceType("replicate"); got != ServiceImageGeneration {
|
|
t.Fatalf("expected image_generation, got %s", got)
|
|
}
|
|
}
|