forked from g8rswimmer/go-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_raw_test.go
99 lines (97 loc) · 3.03 KB
/
user_raw_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package twitter
import (
"reflect"
"testing"
)
func TestUserRaw_UserDictionaries(t *testing.T) {
type fields struct {
Users []*UserObj
Includes *UserRawIncludes
Errors []*ErrorObj
dictionaries map[string]*UserDictionary
}
tests := []struct {
name string
fields fields
want map[string]*UserDictionary
}{
{
name: "success",
fields: fields{
Users: []*UserObj{
{
ID: "2244994945",
Name: "Twitter Dev",
UserName: "TwitterDev",
CreatedAt: "2013-12-14T04:35:55.000Z",
PinnedTweetID: "1255542774432063488",
},
{
ID: "783214",
Name: "Twitter",
UserName: "Twitter",
CreatedAt: "2007-02-20T14:35:54.000Z",
PinnedTweetID: "1274087687469715457",
},
},
Includes: &UserRawIncludes{
Tweets: []*TweetObj{
{
ID: "1255542774432063488",
CreatedAt: "2020-04-29T17:01:38.000Z",
Text: "During these unprecedented times, what’s happening on Twitter can help the world better understand & respond to the pandemic. \n\nWe're launching a free COVID-19 stream endpoint so qualified devs & researchers can study the public conversation in real-time. https://t.co/BPqMcQzhId",
},
{
ID: "1274087687469715457",
CreatedAt: "2020-06-19T21:12:30.000Z",
Text: "📍 Minneapolis\n🗣️ @FredTJoseph https://t.co/lNTOkyguG1",
},
},
},
},
want: map[string]*UserDictionary{
"2244994945": {
User: UserObj{
ID: "2244994945",
Name: "Twitter Dev",
UserName: "TwitterDev",
CreatedAt: "2013-12-14T04:35:55.000Z",
PinnedTweetID: "1255542774432063488",
},
PinnedTweet: &TweetObj{
ID: "1255542774432063488",
CreatedAt: "2020-04-29T17:01:38.000Z",
Text: "During these unprecedented times, what’s happening on Twitter can help the world better understand & respond to the pandemic. \n\nWe're launching a free COVID-19 stream endpoint so qualified devs & researchers can study the public conversation in real-time. https://t.co/BPqMcQzhId",
},
},
"783214": {
User: UserObj{
ID: "783214",
Name: "Twitter",
UserName: "Twitter",
CreatedAt: "2007-02-20T14:35:54.000Z",
PinnedTweetID: "1274087687469715457",
},
PinnedTweet: &TweetObj{
ID: "1274087687469715457",
CreatedAt: "2020-06-19T21:12:30.000Z",
Text: "📍 Minneapolis\n🗣️ @FredTJoseph https://t.co/lNTOkyguG1",
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u := &UserRaw{
Users: tt.fields.Users,
Includes: tt.fields.Includes,
Errors: tt.fields.Errors,
dictionaries: tt.fields.dictionaries,
}
if got := u.UserDictionaries(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("UserRaw.UserDictionaries() = %v, want %v", got, tt.want)
}
})
}
}