Files
JuYou/API/internal/modules/prompt/service_test.go
T
2026-08-25 17:59:42 +08:00

25 lines
959 B
Go

// 提示词模块单元测试,验证固定类型规则和用户输入标准化行为。
package prompt
import "testing"
// TestIsFixedDramaParseType 验证固定提示词类型及空白清理规则。
func TestIsFixedDramaParseType(t *testing.T) {
for _, value := range []string{"剧本解析", " 角色、场景、道具解析 "} {
if !IsFixedDramaParseType(value) {
t.Fatalf("expected %q to be fixed", value)
}
}
if IsFixedDramaParseType("剧本分析") {
t.Fatal("剧本分析不应被识别为固定解析提示词")
}
}
// TestNormalizeCustomPromptInput 验证提示词字段在校验和写入前统一清理两端空白。
func TestNormalizeCustomPromptInput(t *testing.T) {
input := normalizeCustomPromptInput(CustomPromptInput{Name: " 名称 ", Type: " 类型\n", Content: " 内容 "})
if input.Name != "名称" || input.Type != "类型" || input.Content != "内容" {
t.Fatalf("unexpected normalized input: %#v", input)
}
}