Files
creator-hub/internal/douyin/creator_collector_test.go
T

22 lines
959 B
Go

package douyin
import "testing"
func TestParseCreatorWorksPageKeepsPartialMetadata(t *testing.T) {
body := []byte(`{"status_code":0,"has_more":false,"aweme_list":[{"aweme_id":"123","desc":"partial","statistics":{"digg_count":7}}]}`)
works, hasMore, cursor, ok := parseCreatorWorksPage(body)
if !ok || hasMore || cursor != nil || len(works) != 1 {
t.Fatalf("unexpected parsed page: ok=%v hasMore=%v cursor=%v works=%d", ok, hasMore, cursor, len(works))
}
if works[0].CreatedAt != nil || works[0].DiggCount == nil || *works[0].DiggCount != 7 || works[0].CommentCount != nil || works[0].ShareCount != nil {
t.Fatalf("partial metadata was not preserved: %+v", works[0])
}
}
func TestParseCreatorWorksPageRejectsMissingWorkIdentity(t *testing.T) {
body := []byte(`{"status_code":0,"has_more":false,"aweme_list":[{"desc":"no id"}]}`)
if _, _, _, ok := parseCreatorWorksPage(body); ok {
t.Fatal("expected missing work identity to be rejected")
}
}