Improve skip auth test
This commit is contained in:
parent
7393ab5136
commit
41b7e80ee8
3 changed files with 13 additions and 14 deletions
|
|
@ -12,11 +12,12 @@ var (
|
||||||
username = os.Getenv("TWITTER_USERNAME")
|
username = os.Getenv("TWITTER_USERNAME")
|
||||||
password = os.Getenv("TWITTER_PASSWORD")
|
password = os.Getenv("TWITTER_PASSWORD")
|
||||||
email = os.Getenv("TWITTER_EMAIL")
|
email = os.Getenv("TWITTER_EMAIL")
|
||||||
|
skipAuthTest = os.Getenv("SKIP_AUTH_TEST") != ""
|
||||||
testScraper = twitterscraper.New()
|
testScraper = twitterscraper.New()
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" && !skipAuthTest {
|
||||||
err := testScraper.Login(username, password, email)
|
err := testScraper.Login(username, password, email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Login() error = %v", err))
|
panic(fmt.Sprintf("Login() error = %v", err))
|
||||||
|
|
@ -25,7 +26,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAuth(t *testing.T) {
|
func TestAuth(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
scraper := twitterscraper.New()
|
scraper := twitterscraper.New()
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,13 @@ package twitterscraper_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
twitterscraper "github.com/n0madic/twitter-scraper"
|
twitterscraper "github.com/n0madic/twitter-scraper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFetchSearchCursor(t *testing.T) {
|
func TestFetchSearchCursor(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +29,7 @@ func TestFetchSearchCursor(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSearchProfiles(t *testing.T) {
|
func TestGetSearchProfiles(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
|
|
@ -59,7 +58,7 @@ func TestGetSearchProfiles(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestGetSearchTweets(t *testing.T) {
|
func TestGetSearchTweets(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package twitterscraper_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -128,7 +127,7 @@ func TestGetTweetWithMultiplePhotos(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTweetWithGIF(t *testing.T) {
|
func TestGetTweetWithGIF(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
expectedTweet := twitterscraper.Tweet{
|
expectedTweet := twitterscraper.Tweet{
|
||||||
|
|
@ -155,7 +154,7 @@ func TestGetTweetWithGIF(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTweetWithPhotoAndGIF(t *testing.T) {
|
func TestGetTweetWithPhotoAndGIF(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
expectedTweet := twitterscraper.Tweet{
|
expectedTweet := twitterscraper.Tweet{
|
||||||
|
|
@ -299,7 +298,7 @@ func TestTweetViews(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTweetThread(t *testing.T) {
|
func TestTweetThread(t *testing.T) {
|
||||||
if os.Getenv("SKIP_AUTH_TEST") != "" {
|
if skipAuthTest {
|
||||||
t.Skip("Skipping test due to environment variable")
|
t.Skip("Skipping test due to environment variable")
|
||||||
}
|
}
|
||||||
tweet, err := testScraper.GetTweet("1665602315745673217")
|
tweet, err := testScraper.GetTweet("1665602315745673217")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue