Add dupcheck for search test
This commit is contained in:
parent
9a85dfa062
commit
7b1e9d2f07
1 changed files with 7 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ func TestFetchSearchCursor(t *testing.T) {
|
||||||
func TestGetSearchTweets(t *testing.T) {
|
func TestGetSearchTweets(t *testing.T) {
|
||||||
count := 0
|
count := 0
|
||||||
maxTweetsNbr := 250
|
maxTweetsNbr := 250
|
||||||
|
dupcheck := make(map[string]bool)
|
||||||
for tweet := range SearchTweets(context.Background(), "twitter -filter:retweets", maxTweetsNbr) {
|
for tweet := range SearchTweets(context.Background(), "twitter -filter:retweets", maxTweetsNbr) {
|
||||||
if tweet.Error != nil {
|
if tweet.Error != nil {
|
||||||
t.Error(tweet.Error)
|
t.Error(tweet.Error)
|
||||||
|
|
@ -33,6 +34,12 @@ func TestGetSearchTweets(t *testing.T) {
|
||||||
count++
|
count++
|
||||||
if tweet.ID == "" {
|
if tweet.ID == "" {
|
||||||
t.Error("Expected tweet ID is not empty")
|
t.Error("Expected tweet ID is not empty")
|
||||||
|
} else {
|
||||||
|
if dupcheck[tweet.ID] {
|
||||||
|
t.Errorf("Detect duplicated tweet ID: %s", tweet.ID)
|
||||||
|
} else {
|
||||||
|
dupcheck[tweet.ID] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if tweet.PermanentURL == "" {
|
if tweet.PermanentURL == "" {
|
||||||
t.Error("Expected tweet PermanentURL is not empty")
|
t.Error("Expected tweet PermanentURL is not empty")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue