Skip to content

Commit

Permalink
finished 429 unit test scrape_test and sending tweets error back to t…
Browse files Browse the repository at this point in the history
…rigger worker timeout check
  • Loading branch information
jdutchak committed Aug 1, 2024
1 parent a65940c commit 30965ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/scrapers/twitter/tweets.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func ScrapeTweetsByQuery(query string, count int) ([]*TweetResult, error) {
}
tweets = append(tweets, &tweet)
}
return tweets, nil
return tweets, tweets[0].Error
}

// ScrapeTweetsByTrends scrapes the current trending topics on Twitter.
Expand Down
21 changes: 20 additions & 1 deletion pkg/tests/scrape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,21 @@ func TestScrapeTweetsWithMockServer(t *testing.T) {
func TestScrapeTweets(t *testing.T) {
setup()

// // Create a new OracleNode for testing
// testNode, err := masa.NewOracleNode(context.Background(), true)
// if err != nil {
// t.Fatalf("Failed to create test node: %v", err)
// }
// defer testNode.Host.Close()

// // Start the node
// if err := testNode.Start(); err != nil {
// t.Fatalf("Failed to start test node: %v", err)
// }

// // Now we can use the node's NodeTracker
// go testNode.NodeTracker.ClearExpiredWorkerTimeouts()

query := "Sadhguru"
count := 10

Expand Down Expand Up @@ -301,7 +316,11 @@ func TestScrapeTweets(t *testing.T) {
"tweets_sample": string(tweetsData[:min(100, len(tweetsData))]),
}).Debug("[+] Tweets data")

assert.NotNil(t, tweetsData[:10])
if len(tweetsData) > 0 {
assert.NotNil(t, tweetsData[:min(10, len(tweetsData))])
} else {
assert.Nil(t, tweetsData)
}
}
}

Expand Down

0 comments on commit 30965ff

Please sign in to comment.