forked from imperatrona/twitter-scraper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schedule_test.go
52 lines (44 loc) · 985 Bytes
/
schedule_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package twitterscraper_test
import (
"encoding/json"
"fmt"
"testing"
"time"
twitterscraper "github.com/imperatrona/twitter-scraper"
)
func TestFetchScheduledTweets(t *testing.T) {
if skipAuthTest {
t.Skip("Skipping test due to environment variable")
}
scheduled, err := testScraper.FetchScheduledTweets()
if err != nil {
t.Error(err)
}
b, _ := json.Marshal(scheduled)
fmt.Println(string(b))
}
var id string
func TestCreateScheduledTweets(t *testing.T) {
if skipAuthTest {
t.Skip("Skipping test due to environment variable")
}
var err error
id, err = testScraper.CreateScheduledTweet(twitterscraper.TweetSchedule{
Text: "new tweet",
Date: time.Now().Add(time.Hour * 24 * 31),
Medias: nil,
})
if err != nil {
t.Error(err)
}
}
func TestDeleteScheduledTweets(t *testing.T) {
if id == "" {
t.Skip("run TestCreateScheduledTweets before")
}
if err := testScraper.DeleteScheduledTweet(id); err != nil {
t.Error(err)
} else {
id = ""
}
}