diff --git a/scraper/tweet.go b/scraper/tweet.go index dcb6662..970427a 100644 --- a/scraper/tweet.go +++ b/scraper/tweet.go @@ -22,7 +22,7 @@ type Tweet struct { Urls []string Images []string - Mentions []UserID + Mentions []string Hashtags []string QuotedTweet TweetID } @@ -66,7 +66,7 @@ func ParseSingleTweet(apiTweet APITweet) (ret Tweet, err error) { ret.Hashtags = append(ret.Hashtags, hashtag.Text) } for _, mention := range apiTweet.Entities.Mentions { - ret.Mentions = append(ret.Mentions, UserID(mention.UserID)) + ret.Mentions = append(ret.Mentions, mention.UserName) } ret.QuotedTweet = TweetID(apiTweet.QuotedStatusIDStr) diff --git a/scraper/tweet_test.go b/scraper/tweet_test.go index 17510aa..fe4c550 100644 --- a/scraper/tweet_test.go +++ b/scraper/tweet_test.go @@ -47,6 +47,10 @@ func TestParseSingleTweet(t *testing.T) { if actual_text != expected_text { t.Errorf("Expected: %q; got %q", expected_text, actual_text) } + + if len(tweet.Mentions) != 1 || tweet.Mentions[0] != "michaelmalice" { + t.Errorf("Expected %v, got %v", []string{"michaelmalice"}, tweet.Mentions) + } } func TestParseSingleTweet2(t *testing.T) { @@ -101,6 +105,10 @@ func TestParseSingleTweet2(t *testing.T) { if len(tweet1.Images) != 1 { t.Errorf("Expected 1 images but got %d", len(tweet1.Images)) } + + if tweet2.InReplyTo != tweet1.ID { + t.Errorf("Expected %q, got %q", tweet1.ID, tweet2.InReplyTo) + } if tweet1.QuotedTweet != "" { t.Errorf("Incorrectly believes it quote-tweets %q", tweet1.QuotedTweet) }