Change mentions to track usernames rather than user ids
This commit is contained in:
parent
5449b16038
commit
e5337ef0d0
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user