Fix search cursor
This commit is contained in:
parent
0533b6e909
commit
9a85dfa062
4 changed files with 36 additions and 3 deletions
|
|
@ -5,10 +5,28 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestFetchSearchCursor(t *testing.T) {
|
||||
scraper := New()
|
||||
maxTweetsNbr := 150
|
||||
tweetsNbr := 0
|
||||
nextCursor := ""
|
||||
for tweetsNbr < maxTweetsNbr {
|
||||
tweets, cursor, err := scraper.FetchSearchTweets("twitter", maxTweetsNbr, nextCursor)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cursor == "" {
|
||||
t.Fatal("Expected search cursor is not empty")
|
||||
}
|
||||
tweetsNbr += len(tweets)
|
||||
nextCursor = cursor
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSearchTweets(t *testing.T) {
|
||||
count := 0
|
||||
maxTweetsNbr := 250
|
||||
for tweet := range SearchTweets(context.Background(), "twitter scraper data -filter:retweets", maxTweetsNbr) {
|
||||
for tweet := range SearchTweets(context.Background(), "twitter -filter:retweets", maxTweetsNbr) {
|
||||
if tweet.Error != nil {
|
||||
t.Error(tweet.Error)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue