Files
JuYou/API/internal/service/creative_project_test.go
2026-08-25 17:59:42 +08:00

55 lines
1.9 KiB
Go

package service
import "testing"
func TestShortDramaProjectDoesNotRequireLocalization(t *testing.T) {
input := normalizeCreateProjectInput(ProjectInput{
Name: "测试短剧",
StyleID: "00000000-0000-0000-0000-000000000001",
EraType: "modern_city",
AspectRatio: "9:16",
})
if input.ProjectType != "premium_drama" {
t.Fatalf("expected request without localization to be treated as premium_drama, got %q", input.ProjectType)
}
if err := validateProjectInput(input); err != nil {
t.Fatalf("short drama project should not require localization: %v", err)
}
}
func TestVideoRedrawScriptUsesCreationDefaults(t *testing.T) {
followerCount := "百万粉丝"
input := normalizeCreateProjectInput(ProjectInput{
ProjectType: "video_redraw",
Name: "测试剧本",
StyleID: "00000000-0000-0000-0000-000000000001",
ShortDramaType: "都市情感",
PlayCount: "全网播放破亿",
AudienceProfile: "25 至 35 岁女性",
Producer: "测试出品方",
CastMembers: []ProjectCastMemberInput{{
Name: "测试主演", FollowerCount: &followerCount,
}},
})
if input.EraType != "modern_city" || input.AspectRatio != "9:16" {
t.Fatalf("unexpected redraw creation defaults: era=%q ratio=%q", input.EraType, input.AspectRatio)
}
if input.Localization == nil || *input.Localization != "china" {
t.Fatalf("expected default localization china, got %v", input.Localization)
}
if err := validateProjectInput(input); err != nil {
t.Fatalf("redraw project metadata should be valid after defaults: %v", err)
}
}
func TestVideoRedrawProjectOnlyRequiresName(t *testing.T) {
input := normalizeCreateProjectInput(ProjectInput{
ProjectType: "video_redraw",
Name: "测试剧本",
StyleID: "00000000-0000-0000-0000-000000000001",
})
if err := validateProjectInput(input); err != nil {
t.Fatalf("redraw project optional metadata should be accepted: %v", err)
}
}