Files
creator-hub/internal/creator/competitor_share_jobs_test.go
T
2026-09-21 16:44:09 +08:00

30 lines
869 B
Go

package creator
import (
"errors"
"testing"
)
func TestNormalizeCompetitorShareJobInput(t *testing.T) {
job, err := normalizeCompetitorShareJobInput(CompetitorShareJobInput{
Platform: " douyin ",
ShareURL: " https://v.douyin.com/share-a/ ",
})
if err != nil {
t.Fatal(err)
}
if job.Platform != PlatformDouyin || job.ShareURL != "https://v.douyin.com/share-a/" || job.Tags == nil {
t.Fatalf("normalized job = %+v", job)
}
for _, input := range []CompetitorShareJobInput{
{Platform: PlatformDouyin, ShareURL: "http://v.douyin.com/share-a/"},
{Platform: "unsupported", ShareURL: "https://v.douyin.com/share-a/"},
{Platform: PlatformDouyin, ShareURL: "https://v.douyin.com/share-a/#fragment"},
} {
if _, err := normalizeCompetitorShareJobInput(input); !errors.Is(err, ErrInvalid) {
t.Fatalf("input %+v returned err=%v", input, err)
}
}
}