Total refactoring
Used guest frontend API BREAKING CHANGE: remove tweet.HTML property Loading more information Minor fixes and changes
This commit is contained in:
parent
1c582e142e
commit
edad8f6393
15 changed files with 628 additions and 497 deletions
|
|
@ -2,28 +2,30 @@ package twitterscraper
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
)
|
||||
|
||||
func TestGetProfile(t *testing.T) {
|
||||
// loc := time.FixedZone("UTC", 0)
|
||||
// joined := time.Date(2007, 02, 20, 6, 35, 0, 0, loc)
|
||||
loc := time.FixedZone("UTC", 0)
|
||||
joined := time.Date(2007, 02, 20, 14, 35, 54, 0, loc)
|
||||
sample := Profile{
|
||||
Avatar: "https://pbs.twimg.com/profile_images/1308010958862905345/-SGZioPb_normal.jpg",
|
||||
// Banner: "https://pbs.twimg.com/profile_banners/783214/1596041768/1500x500",
|
||||
Avatar: "https://pbs.twimg.com/profile_images/1308010958862905345/-SGZioPb_normal.jpg",
|
||||
Banner: "https://pbs.twimg.com/profile_banners/783214/1604501727",
|
||||
Biography: "What's happening!?",
|
||||
// Birthday: "March 21",
|
||||
IsPrivate: false,
|
||||
IsVerified: true,
|
||||
// Joined: &joined,
|
||||
Location: "everywhere",
|
||||
Name: "Twitter",
|
||||
URL: "https://twitter.com/Twitter",
|
||||
// UserID: "783214",
|
||||
Username: "Twitter",
|
||||
Website: "about.twitter.com",
|
||||
// Birthday: "March 21",
|
||||
IsPrivate: false,
|
||||
IsVerified: true,
|
||||
Joined: &joined,
|
||||
Location: "everywhere",
|
||||
Name: "Twitter",
|
||||
PinnedTweetIDs: []string{},
|
||||
URL: "https://twitter.com/Twitter",
|
||||
UserID: "783214",
|
||||
Username: "Twitter",
|
||||
Website: "https://about.twitter.com/",
|
||||
}
|
||||
|
||||
profile, err := GetProfile("Twitter")
|
||||
|
|
@ -34,7 +36,9 @@ func TestGetProfile(t *testing.T) {
|
|||
cmpOptions := cmp.Options{
|
||||
cmpopts.IgnoreFields(Profile{}, "FollowersCount"),
|
||||
cmpopts.IgnoreFields(Profile{}, "FollowingCount"),
|
||||
cmpopts.IgnoreFields(Profile{}, "FriendsCount"),
|
||||
cmpopts.IgnoreFields(Profile{}, "LikesCount"),
|
||||
cmpopts.IgnoreFields(Profile{}, "ListedCount"),
|
||||
cmpopts.IgnoreFields(Profile{}, "TweetsCount"),
|
||||
}
|
||||
if diff := cmp.Diff(sample, profile, cmpOptions...); diff != "" {
|
||||
|
|
@ -47,9 +51,9 @@ func TestGetProfile(t *testing.T) {
|
|||
if profile.FollowingCount == 0 {
|
||||
t.Error("Expected FollowingCount is greater than zero")
|
||||
}
|
||||
// if profile.LikesCount == 0 {
|
||||
// t.Error("Expected LikesCount is greater than zero")
|
||||
// }
|
||||
if profile.LikesCount == 0 {
|
||||
t.Error("Expected LikesCount is greater than zero")
|
||||
}
|
||||
if profile.TweetsCount == 0 {
|
||||
t.Error("Expected TweetsCount is greater than zero")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue