add scrap tweets for any search query feature

This commit is contained in:
xisco 2020-05-14 14:59:33 +02:00
parent 37bb62a82a
commit 2abfb27a7b
4 changed files with 147 additions and 1 deletions

36
search_test.go Normal file
View file

@ -0,0 +1,36 @@
package twitterscraper
import "testing"
func TestGetSearchTweets(t *testing.T) {
count := 0
for tweet := range GetSearchTweets("twitter scraper data -filter:retweets", 50) {
if tweet.Error != nil {
t.Error(tweet.Error)
} else {
count++
if tweet.HTML == "" {
t.Error("Expected tweet HTML is not empty")
}
if tweet.ID == "" {
t.Error("Expected tweet ID is not empty")
}
if tweet.PermanentURL == "" {
t.Error("Expected tweet PermanentURL is not empty")
}
if tweet.Text == "" {
t.Error("Expected tweet Text is not empty")
}
if tweet.TimeParsed.IsZero() {
t.Error("Expected tweet TimeParsed is not zero")
}
if tweet.Timestamp == 0 {
t.Error("Expected tweet Timestamp is greater than zero")
}
}
}
if count == 0 {
t.Error("Expected tweets count is greater than zero")
}
}