6e6b899071
CI / docker (push) Successful in 7m37s
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
918 B
Go
39 lines
918 B
Go
package chat
|
|
|
|
import "testing"
|
|
|
|
func TestSanitizeTitle(t *testing.T) {
|
|
if got := sanitizeTitle(` "测试标题" `); got != "测试标题" {
|
|
t.Fatalf("unexpected: %q", got)
|
|
}
|
|
long := stringsRepeat("标题", 20)
|
|
got := sanitizeTitle(long)
|
|
if len([]rune(got)) > 30 {
|
|
t.Fatalf("title too long: %d", len([]rune(got)))
|
|
}
|
|
}
|
|
|
|
func TestTitleAlreadySummarized(t *testing.T) {
|
|
if titleAlreadySummarized(map[string]any{}) {
|
|
t.Fatal("expected false")
|
|
}
|
|
if !titleAlreadySummarized(map[string]any{"title_summarized": true}) {
|
|
t.Fatal("expected true")
|
|
}
|
|
}
|
|
|
|
func stringsRepeat(s string, n int) string {
|
|
out := ""
|
|
for i := 0; i < n; i++ {
|
|
out += s
|
|
}
|
|
return out
|
|
}
|
|
|
|
func TestParseChatCompletionContent(t *testing.T) {
|
|
body := []byte(`{"choices":[{"message":{"content":" Atlas 部署方案 "}}]}`)
|
|
if got := parseChatCompletionContent(body); got != "Atlas 部署方案" {
|
|
t.Fatalf("unexpected: %q", got)
|
|
}
|
|
}
|