Fix test
This commit is contained in:
parent
1080741bc6
commit
34aa1c1819
1 changed files with 7 additions and 6 deletions
|
|
@ -9,6 +9,12 @@ import (
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cmpOptions = cmp.Options{
|
||||||
|
cmpopts.IgnoreFields(Tweet{}, "Likes"),
|
||||||
|
cmpopts.IgnoreFields(Tweet{}, "Replies"),
|
||||||
|
cmpopts.IgnoreFields(Tweet{}, "Retweets"),
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetTweets(t *testing.T) {
|
func TestGetTweets(t *testing.T) {
|
||||||
count := 0
|
count := 0
|
||||||
maxTweetsNbr := 300
|
maxTweetsNbr := 300
|
||||||
|
|
@ -84,11 +90,6 @@ func TestGetTweet(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else {
|
} else {
|
||||||
cmpOptions := cmp.Options{
|
|
||||||
cmpopts.IgnoreFields(Tweet{}, "Likes"),
|
|
||||||
cmpopts.IgnoreFields(Tweet{}, "Replies"),
|
|
||||||
cmpopts.IgnoreFields(Tweet{}, "Retweets"),
|
|
||||||
}
|
|
||||||
if diff := cmp.Diff(sample, *tweet, cmpOptions...); diff != "" {
|
if diff := cmp.Diff(sample, *tweet, cmpOptions...); diff != "" {
|
||||||
t.Error("Resulting tweet does not match the sample", diff)
|
t.Error("Resulting tweet does not match the sample", diff)
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +157,7 @@ func TestRetweet(t *testing.T) {
|
||||||
if !tweet.IsRetweet {
|
if !tweet.IsRetweet {
|
||||||
t.Error("IsRetweet must be True")
|
t.Error("IsRetweet must be True")
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(sample, tweet.RetweetedStatus); diff != "" {
|
if diff := cmp.Diff(sample, tweet.RetweetedStatus, cmpOptions...); diff != "" {
|
||||||
t.Error("Resulting retweet does not match the sample", diff)
|
t.Error("Resulting retweet does not match the sample", diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue