-
Notifications
You must be signed in to change notification settings - Fork 62
/
UserRepo.go
331 lines (272 loc) · 9.91 KB
/
UserRepo.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
// Code generated by mockery v2.16.0. DO NOT EDIT.
package mocks
import (
context "context"
model "github.com/bangumi/server/internal/model"
mock "github.com/stretchr/testify/mock"
user "github.com/bangumi/server/internal/user"
)
// UserRepo is an autogenerated mock type for the Repo type
type UserRepo struct {
mock.Mock
}
type UserRepo_Expecter struct {
mock *mock.Mock
}
func (_m *UserRepo) EXPECT() *UserRepo_Expecter {
return &UserRepo_Expecter{mock: &_m.Mock}
}
// CheckIsFriendToOthers provides a mock function with given fields: ctx, selfID, otherIDs
func (_m *UserRepo) CheckIsFriendToOthers(ctx context.Context, selfID model.UserID, otherIDs ...model.UserID) (bool, error) {
_va := make([]interface{}, len(otherIDs))
for _i := range otherIDs {
_va[_i] = otherIDs[_i]
}
var _ca []interface{}
_ca = append(_ca, ctx, selfID)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
var r0 bool
if rf, ok := ret.Get(0).(func(context.Context, model.UserID, ...model.UserID) bool); ok {
r0 = rf(ctx, selfID, otherIDs...)
} else {
r0 = ret.Get(0).(bool)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, model.UserID, ...model.UserID) error); ok {
r1 = rf(ctx, selfID, otherIDs...)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_CheckIsFriendToOthers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckIsFriendToOthers'
type UserRepo_CheckIsFriendToOthers_Call struct {
*mock.Call
}
// CheckIsFriendToOthers is a helper method to define mock.On call
// - ctx context.Context
// - selfID model.UserID
// - otherIDs ...model.UserID
func (_e *UserRepo_Expecter) CheckIsFriendToOthers(ctx interface{}, selfID interface{}, otherIDs ...interface{}) *UserRepo_CheckIsFriendToOthers_Call {
return &UserRepo_CheckIsFriendToOthers_Call{Call: _e.mock.On("CheckIsFriendToOthers",
append([]interface{}{ctx, selfID}, otherIDs...)...)}
}
func (_c *UserRepo_CheckIsFriendToOthers_Call) Run(run func(ctx context.Context, selfID model.UserID, otherIDs ...model.UserID)) *UserRepo_CheckIsFriendToOthers_Call {
_c.Call.Run(func(args mock.Arguments) {
variadicArgs := make([]model.UserID, len(args)-2)
for i, a := range args[2:] {
if a != nil {
variadicArgs[i] = a.(model.UserID)
}
}
run(args[0].(context.Context), args[1].(model.UserID), variadicArgs...)
})
return _c
}
func (_c *UserRepo_CheckIsFriendToOthers_Call) Return(_a0 bool, _a1 error) *UserRepo_CheckIsFriendToOthers_Call {
_c.Call.Return(_a0, _a1)
return _c
}
// GetByID provides a mock function with given fields: ctx, userID
func (_m *UserRepo) GetByID(ctx context.Context, userID model.UserID) (user.User, error) {
ret := _m.Called(ctx, userID)
var r0 user.User
if rf, ok := ret.Get(0).(func(context.Context, model.UserID) user.User); ok {
r0 = rf(ctx, userID)
} else {
r0 = ret.Get(0).(user.User)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, model.UserID) error); ok {
r1 = rf(ctx, userID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID'
type UserRepo_GetByID_Call struct {
*mock.Call
}
// GetByID is a helper method to define mock.On call
// - ctx context.Context
// - userID model.UserID
func (_e *UserRepo_Expecter) GetByID(ctx interface{}, userID interface{}) *UserRepo_GetByID_Call {
return &UserRepo_GetByID_Call{Call: _e.mock.On("GetByID", ctx, userID)}
}
func (_c *UserRepo_GetByID_Call) Run(run func(ctx context.Context, userID model.UserID)) *UserRepo_GetByID_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(model.UserID))
})
return _c
}
func (_c *UserRepo_GetByID_Call) Return(_a0 user.User, _a1 error) *UserRepo_GetByID_Call {
_c.Call.Return(_a0, _a1)
return _c
}
// GetByIDs provides a mock function with given fields: ctx, ids
func (_m *UserRepo) GetByIDs(ctx context.Context, ids []model.UserID) (map[model.UserID]user.User, error) {
ret := _m.Called(ctx, ids)
var r0 map[model.UserID]user.User
if rf, ok := ret.Get(0).(func(context.Context, []model.UserID) map[model.UserID]user.User); ok {
r0 = rf(ctx, ids)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[model.UserID]user.User)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, []model.UserID) error); ok {
r1 = rf(ctx, ids)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_GetByIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByIDs'
type UserRepo_GetByIDs_Call struct {
*mock.Call
}
// GetByIDs is a helper method to define mock.On call
// - ctx context.Context
// - ids []model.UserID
func (_e *UserRepo_Expecter) GetByIDs(ctx interface{}, ids interface{}) *UserRepo_GetByIDs_Call {
return &UserRepo_GetByIDs_Call{Call: _e.mock.On("GetByIDs", ctx, ids)}
}
func (_c *UserRepo_GetByIDs_Call) Run(run func(ctx context.Context, ids []model.UserID)) *UserRepo_GetByIDs_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].([]model.UserID))
})
return _c
}
func (_c *UserRepo_GetByIDs_Call) Return(_a0 map[model.UserID]user.User, _a1 error) *UserRepo_GetByIDs_Call {
_c.Call.Return(_a0, _a1)
return _c
}
// GetByName provides a mock function with given fields: ctx, username
func (_m *UserRepo) GetByName(ctx context.Context, username string) (user.User, error) {
ret := _m.Called(ctx, username)
var r0 user.User
if rf, ok := ret.Get(0).(func(context.Context, string) user.User); ok {
r0 = rf(ctx, username)
} else {
r0 = ret.Get(0).(user.User)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = rf(ctx, username)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName'
type UserRepo_GetByName_Call struct {
*mock.Call
}
// GetByName is a helper method to define mock.On call
// - ctx context.Context
// - username string
func (_e *UserRepo_Expecter) GetByName(ctx interface{}, username interface{}) *UserRepo_GetByName_Call {
return &UserRepo_GetByName_Call{Call: _e.mock.On("GetByName", ctx, username)}
}
func (_c *UserRepo_GetByName_Call) Run(run func(ctx context.Context, username string)) *UserRepo_GetByName_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *UserRepo_GetByName_Call) Return(_a0 user.User, _a1 error) *UserRepo_GetByName_Call {
_c.Call.Return(_a0, _a1)
return _c
}
// GetFieldsByIDs provides a mock function with given fields: ctx, ids
func (_m *UserRepo) GetFieldsByIDs(ctx context.Context, ids []model.UserID) (map[model.UserID]user.Fields, error) {
ret := _m.Called(ctx, ids)
var r0 map[model.UserID]user.Fields
if rf, ok := ret.Get(0).(func(context.Context, []model.UserID) map[model.UserID]user.Fields); ok {
r0 = rf(ctx, ids)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[model.UserID]user.Fields)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, []model.UserID) error); ok {
r1 = rf(ctx, ids)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_GetFieldsByIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFieldsByIDs'
type UserRepo_GetFieldsByIDs_Call struct {
*mock.Call
}
// GetFieldsByIDs is a helper method to define mock.On call
// - ctx context.Context
// - ids []model.UserID
func (_e *UserRepo_Expecter) GetFieldsByIDs(ctx interface{}, ids interface{}) *UserRepo_GetFieldsByIDs_Call {
return &UserRepo_GetFieldsByIDs_Call{Call: _e.mock.On("GetFieldsByIDs", ctx, ids)}
}
func (_c *UserRepo_GetFieldsByIDs_Call) Run(run func(ctx context.Context, ids []model.UserID)) *UserRepo_GetFieldsByIDs_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].([]model.UserID))
})
return _c
}
func (_c *UserRepo_GetFieldsByIDs_Call) Return(_a0 map[model.UserID]user.Fields, _a1 error) *UserRepo_GetFieldsByIDs_Call {
_c.Call.Return(_a0, _a1)
return _c
}
// GetFriends provides a mock function with given fields: ctx, userID
func (_m *UserRepo) GetFriends(ctx context.Context, userID model.UserID) (map[model.UserID]user.FriendItem, error) {
ret := _m.Called(ctx, userID)
var r0 map[model.UserID]user.FriendItem
if rf, ok := ret.Get(0).(func(context.Context, model.UserID) map[model.UserID]user.FriendItem); ok {
r0 = rf(ctx, userID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[model.UserID]user.FriendItem)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, model.UserID) error); ok {
r1 = rf(ctx, userID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UserRepo_GetFriends_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFriends'
type UserRepo_GetFriends_Call struct {
*mock.Call
}
// GetFriends is a helper method to define mock.On call
// - ctx context.Context
// - userID model.UserID
func (_e *UserRepo_Expecter) GetFriends(ctx interface{}, userID interface{}) *UserRepo_GetFriends_Call {
return &UserRepo_GetFriends_Call{Call: _e.mock.On("GetFriends", ctx, userID)}
}
func (_c *UserRepo_GetFriends_Call) Run(run func(ctx context.Context, userID model.UserID)) *UserRepo_GetFriends_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(model.UserID))
})
return _c
}
func (_c *UserRepo_GetFriends_Call) Return(_a0 map[model.UserID]user.FriendItem, _a1 error) *UserRepo_GetFriends_Call {
_c.Call.Return(_a0, _a1)
return _c
}
type mockConstructorTestingTNewUserRepo interface {
mock.TestingT
Cleanup(func())
}
// NewUserRepo creates a new instance of UserRepo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewUserRepo(t mockConstructorTestingTNewUserRepo) *UserRepo {
mock := &UserRepo{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}