2024-02-23 10:34:33 +03:00
|
|
|
package twitterscraper_test
|
|
|
|
|
|
|
|
|
|
import (
|
2024-02-23 10:58:24 +03:00
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
2024-02-23 10:34:33 +03:00
|
|
|
"testing"
|
2024-02-23 11:24:34 +03:00
|
|
|
"time"
|
2024-02-23 10:34:33 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestFetchScheduledTweets(t *testing.T) {
|
2024-03-08 19:23:39 +03:00
|
|
|
if skipAuthTest {
|
|
|
|
|
t.Skip("Skipping test due to environment variable")
|
|
|
|
|
}
|
2024-02-23 10:58:24 +03:00
|
|
|
scheduled, err := testScraper.FetchScheduledTweets()
|
2024-02-23 10:34:33 +03:00
|
|
|
if err != nil {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
2024-02-23 10:58:24 +03:00
|
|
|
|
|
|
|
|
b, _ := json.Marshal(scheduled)
|
|
|
|
|
fmt.Println(string(b))
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 11:24:34 +03:00
|
|
|
var id string
|
|
|
|
|
|
|
|
|
|
func TestCreateScheduledTweets(t *testing.T) {
|
2024-03-08 19:23:39 +03:00
|
|
|
if skipAuthTest {
|
|
|
|
|
t.Skip("Skipping test due to environment variable")
|
|
|
|
|
}
|
2024-02-23 11:24:34 +03:00
|
|
|
var err error
|
|
|
|
|
id, err = testScraper.CreateScheduledTweet("new tweet", time.Now().Add(time.Hour*24*31))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 10:58:24 +03:00
|
|
|
func TestDeleteScheduledTweets(t *testing.T) {
|
2024-02-23 11:24:34 +03:00
|
|
|
if id == "" {
|
|
|
|
|
t.Skip("run TestCreateScheduledTweets before")
|
|
|
|
|
}
|
|
|
|
|
if err := testScraper.DeleteScheduledTweet(id); err != nil {
|
2024-02-23 10:58:24 +03:00
|
|
|
t.Error(err)
|
2024-02-23 11:24:34 +03:00
|
|
|
} else {
|
|
|
|
|
id = ""
|
2024-02-23 10:58:24 +03:00
|
|
|
}
|
2024-02-23 10:34:33 +03:00
|
|
|
}
|