use Context to send cancelation signals to groutines

This commit is contained in:
mind1949 2020-06-12 21:31:08 +08:00
parent bf3225765d
commit 5048018d48
5 changed files with 42 additions and 8 deletions

View file

@ -1,12 +1,13 @@
package twitterscraper
import (
"context"
"testing"
)
func TestGetTweets(t *testing.T) {
count := 0
for tweet := range GetTweets("nomadic_ua", 2) {
for tweet := range GetTweets(context.Background(), "nomadic_ua", 2) {
if tweet.Error != nil {
t.Error(tweet.Error)
} else {