Use global test scraper with auth

This commit is contained in:
Alexander Sheiko 2023-07-03 15:06:56 +03:00
parent d34f982b0d
commit 5f380af184
3 changed files with 27 additions and 66 deletions

View file

@ -1,6 +1,7 @@
package twitterscraper_test
import (
"fmt"
"os"
"testing"
@ -8,11 +9,21 @@ import (
)
var (
username = os.Getenv("TWITTER_USERNAME")
password = os.Getenv("TWITTER_PASSWORD")
email = os.Getenv("TWITTER_EMAIL")
username = os.Getenv("TWITTER_USERNAME")
password = os.Getenv("TWITTER_PASSWORD")
email = os.Getenv("TWITTER_EMAIL")
testScraper = twitterscraper.New()
)
func init() {
if username != "" && password != "" {
err := testScraper.Login(username, password, email)
if err != nil {
panic(fmt.Sprintf("Login() error = %v", err))
}
}
}
func TestAuth(t *testing.T) {
if os.Getenv("SKIP_AUTH_TEST") != "" {
t.Skip("Skipping test due to environment variable")