This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
twitterapi_moq_test.go
302 lines (280 loc) · 8.38 KB
/
twitterapi_moq_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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package main
import (
"github.com/ChimeraCoder/anaconda"
"net/url"
"sync"
)
// Ensure, that TwitterAPIMock does implement TwitterAPI.
// If this is not the case, regenerate this file with moq.
var _ TwitterAPI = &TwitterAPIMock{}
// TwitterAPIMock is a mock implementation of TwitterAPI.
//
// func TestSomethingThatUsesTwitterAPI(t *testing.T) {
//
// // make and configure a mocked TwitterAPI
// mockedTwitterAPI := &TwitterAPIMock{
// DeleteTweetFunc: func(id int64, trimUser bool) (anaconda.Tweet, error) {
// panic("mock out the DeleteTweet method")
// },
// GetFavoritesFunc: func(v url.Values) ([]anaconda.Tweet, error) {
// panic("mock out the GetFavorites method")
// },
// GetSelfFunc: func(v url.Values) (anaconda.User, error) {
// panic("mock out the GetSelf method")
// },
// GetUserTimelineFunc: func(v url.Values) ([]anaconda.Tweet, error) {
// panic("mock out the GetUserTimeline method")
// },
// UnRetweetFunc: func(id int64, trimUser bool) (anaconda.Tweet, error) {
// panic("mock out the UnRetweet method")
// },
// UnfavoriteFunc: func(id int64) (anaconda.Tweet, error) {
// panic("mock out the Unfavorite method")
// },
// }
//
// // use mockedTwitterAPI in code that requires TwitterAPI
// // and then make assertions.
//
// }
type TwitterAPIMock struct {
// DeleteTweetFunc mocks the DeleteTweet method.
DeleteTweetFunc func(id int64, trimUser bool) (anaconda.Tweet, error)
// GetFavoritesFunc mocks the GetFavorites method.
GetFavoritesFunc func(v url.Values) ([]anaconda.Tweet, error)
// GetSelfFunc mocks the GetSelf method.
GetSelfFunc func(v url.Values) (anaconda.User, error)
// GetUserTimelineFunc mocks the GetUserTimeline method.
GetUserTimelineFunc func(v url.Values) ([]anaconda.Tweet, error)
// UnRetweetFunc mocks the UnRetweet method.
UnRetweetFunc func(id int64, trimUser bool) (anaconda.Tweet, error)
// UnfavoriteFunc mocks the Unfavorite method.
UnfavoriteFunc func(id int64) (anaconda.Tweet, error)
// calls tracks calls to the methods.
calls struct {
// DeleteTweet holds details about calls to the DeleteTweet method.
DeleteTweet []struct {
// ID is the id argument value.
ID int64
// TrimUser is the trimUser argument value.
TrimUser bool
}
// GetFavorites holds details about calls to the GetFavorites method.
GetFavorites []struct {
// V is the v argument value.
V url.Values
}
// GetSelf holds details about calls to the GetSelf method.
GetSelf []struct {
// V is the v argument value.
V url.Values
}
// GetUserTimeline holds details about calls to the GetUserTimeline method.
GetUserTimeline []struct {
// V is the v argument value.
V url.Values
}
// UnRetweet holds details about calls to the UnRetweet method.
UnRetweet []struct {
// ID is the id argument value.
ID int64
// TrimUser is the trimUser argument value.
TrimUser bool
}
// Unfavorite holds details about calls to the Unfavorite method.
Unfavorite []struct {
// ID is the id argument value.
ID int64
}
}
lockDeleteTweet sync.RWMutex
lockGetFavorites sync.RWMutex
lockGetSelf sync.RWMutex
lockGetUserTimeline sync.RWMutex
lockUnRetweet sync.RWMutex
lockUnfavorite sync.RWMutex
}
// DeleteTweet calls DeleteTweetFunc.
func (mock *TwitterAPIMock) DeleteTweet(id int64, trimUser bool) (anaconda.Tweet, error) {
if mock.DeleteTweetFunc == nil {
panic("TwitterAPIMock.DeleteTweetFunc: method is nil but TwitterAPI.DeleteTweet was just called")
}
callInfo := struct {
ID int64
TrimUser bool
}{
ID: id,
TrimUser: trimUser,
}
mock.lockDeleteTweet.Lock()
mock.calls.DeleteTweet = append(mock.calls.DeleteTweet, callInfo)
mock.lockDeleteTweet.Unlock()
return mock.DeleteTweetFunc(id, trimUser)
}
// DeleteTweetCalls gets all the calls that were made to DeleteTweet.
// Check the length with:
// len(mockedTwitterAPI.DeleteTweetCalls())
func (mock *TwitterAPIMock) DeleteTweetCalls() []struct {
ID int64
TrimUser bool
} {
var calls []struct {
ID int64
TrimUser bool
}
mock.lockDeleteTweet.RLock()
calls = mock.calls.DeleteTweet
mock.lockDeleteTweet.RUnlock()
return calls
}
// GetFavorites calls GetFavoritesFunc.
func (mock *TwitterAPIMock) GetFavorites(v url.Values) ([]anaconda.Tweet, error) {
if mock.GetFavoritesFunc == nil {
panic("TwitterAPIMock.GetFavoritesFunc: method is nil but TwitterAPI.GetFavorites was just called")
}
callInfo := struct {
V url.Values
}{
V: v,
}
mock.lockGetFavorites.Lock()
mock.calls.GetFavorites = append(mock.calls.GetFavorites, callInfo)
mock.lockGetFavorites.Unlock()
return mock.GetFavoritesFunc(v)
}
// GetFavoritesCalls gets all the calls that were made to GetFavorites.
// Check the length with:
// len(mockedTwitterAPI.GetFavoritesCalls())
func (mock *TwitterAPIMock) GetFavoritesCalls() []struct {
V url.Values
} {
var calls []struct {
V url.Values
}
mock.lockGetFavorites.RLock()
calls = mock.calls.GetFavorites
mock.lockGetFavorites.RUnlock()
return calls
}
// GetSelf calls GetSelfFunc.
func (mock *TwitterAPIMock) GetSelf(v url.Values) (anaconda.User, error) {
if mock.GetSelfFunc == nil {
panic("TwitterAPIMock.GetSelfFunc: method is nil but TwitterAPI.GetSelf was just called")
}
callInfo := struct {
V url.Values
}{
V: v,
}
mock.lockGetSelf.Lock()
mock.calls.GetSelf = append(mock.calls.GetSelf, callInfo)
mock.lockGetSelf.Unlock()
return mock.GetSelfFunc(v)
}
// GetSelfCalls gets all the calls that were made to GetSelf.
// Check the length with:
// len(mockedTwitterAPI.GetSelfCalls())
func (mock *TwitterAPIMock) GetSelfCalls() []struct {
V url.Values
} {
var calls []struct {
V url.Values
}
mock.lockGetSelf.RLock()
calls = mock.calls.GetSelf
mock.lockGetSelf.RUnlock()
return calls
}
// GetUserTimeline calls GetUserTimelineFunc.
func (mock *TwitterAPIMock) GetUserTimeline(v url.Values) ([]anaconda.Tweet, error) {
if mock.GetUserTimelineFunc == nil {
panic("TwitterAPIMock.GetUserTimelineFunc: method is nil but TwitterAPI.GetUserTimeline was just called")
}
callInfo := struct {
V url.Values
}{
V: v,
}
mock.lockGetUserTimeline.Lock()
mock.calls.GetUserTimeline = append(mock.calls.GetUserTimeline, callInfo)
mock.lockGetUserTimeline.Unlock()
return mock.GetUserTimelineFunc(v)
}
// GetUserTimelineCalls gets all the calls that were made to GetUserTimeline.
// Check the length with:
// len(mockedTwitterAPI.GetUserTimelineCalls())
func (mock *TwitterAPIMock) GetUserTimelineCalls() []struct {
V url.Values
} {
var calls []struct {
V url.Values
}
mock.lockGetUserTimeline.RLock()
calls = mock.calls.GetUserTimeline
mock.lockGetUserTimeline.RUnlock()
return calls
}
// UnRetweet calls UnRetweetFunc.
func (mock *TwitterAPIMock) UnRetweet(id int64, trimUser bool) (anaconda.Tweet, error) {
if mock.UnRetweetFunc == nil {
panic("TwitterAPIMock.UnRetweetFunc: method is nil but TwitterAPI.UnRetweet was just called")
}
callInfo := struct {
ID int64
TrimUser bool
}{
ID: id,
TrimUser: trimUser,
}
mock.lockUnRetweet.Lock()
mock.calls.UnRetweet = append(mock.calls.UnRetweet, callInfo)
mock.lockUnRetweet.Unlock()
return mock.UnRetweetFunc(id, trimUser)
}
// UnRetweetCalls gets all the calls that were made to UnRetweet.
// Check the length with:
// len(mockedTwitterAPI.UnRetweetCalls())
func (mock *TwitterAPIMock) UnRetweetCalls() []struct {
ID int64
TrimUser bool
} {
var calls []struct {
ID int64
TrimUser bool
}
mock.lockUnRetweet.RLock()
calls = mock.calls.UnRetweet
mock.lockUnRetweet.RUnlock()
return calls
}
// Unfavorite calls UnfavoriteFunc.
func (mock *TwitterAPIMock) Unfavorite(id int64) (anaconda.Tweet, error) {
if mock.UnfavoriteFunc == nil {
panic("TwitterAPIMock.UnfavoriteFunc: method is nil but TwitterAPI.Unfavorite was just called")
}
callInfo := struct {
ID int64
}{
ID: id,
}
mock.lockUnfavorite.Lock()
mock.calls.Unfavorite = append(mock.calls.Unfavorite, callInfo)
mock.lockUnfavorite.Unlock()
return mock.UnfavoriteFunc(id)
}
// UnfavoriteCalls gets all the calls that were made to Unfavorite.
// Check the length with:
// len(mockedTwitterAPI.UnfavoriteCalls())
func (mock *TwitterAPIMock) UnfavoriteCalls() []struct {
ID int64
} {
var calls []struct {
ID int64
}
mock.lockUnfavorite.RLock()
calls = mock.calls.Unfavorite
mock.lockUnfavorite.RUnlock()
return calls
}