• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 1494786857

14 Oct 2024 10:01AM UTC coverage: 72.891% (-1.2%) from 74.094%
1494786857

Pull #100

gitlab-ci

tranchitella
chore: centralize the mock generator across the different services

Changelog: None
Ticket: None

Signed-off-by: Fabio Tranchitella <fabio@tranchitella.eu>
Pull Request #100: chore: centralize the mock generator across the different services

4399 of 6347 branches covered (69.31%)

Branch coverage included in aggregate %.

722 of 2034 new or added lines in 44 files covered. (35.5%)

197 existing lines in 36 files now uncovered.

42530 of 58035 relevant lines covered (73.28%)

28.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.95
/backend/services/useradm/user/mocks/App.go
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
// Code generated by mockery v2.45.1. DO NOT EDIT.
16

17
package mocks
18

19
import (
20
        context "context"
21

22
        jwt "github.com/mendersoftware/mender-server/services/useradm/jwt"
23
        mock "github.com/stretchr/testify/mock"
24

25
        model "github.com/mendersoftware/mender-server/services/useradm/model"
26

27
        useradm "github.com/mendersoftware/mender-server/services/useradm/user"
28
)
29

30
// App is an autogenerated mock type for the App type
31
type App struct {
32
        mock.Mock
33
}
34

35
// CreateTenant provides a mock function with given fields: ctx, tenant
36
func (_m *App) CreateTenant(ctx context.Context, tenant model.NewTenant) error {
1✔
37
        ret := _m.Called(ctx, tenant)
1✔
38

1✔
39
        if len(ret) == 0 {
1✔
NEW
40
                panic("no return value specified for CreateTenant")
×
41
        }
42

43
        var r0 error
1✔
44
        if rf, ok := ret.Get(0).(func(context.Context, model.NewTenant) error); ok {
1✔
45
                r0 = rf(ctx, tenant)
×
46
        } else {
1✔
47
                r0 = ret.Error(0)
1✔
48
        }
1✔
49

50
        return r0
1✔
51
}
52

53
// CreateUser provides a mock function with given fields: ctx, u
54
func (_m *App) CreateUser(ctx context.Context, u *model.User) error {
1✔
55
        ret := _m.Called(ctx, u)
1✔
56

1✔
57
        if len(ret) == 0 {
1✔
NEW
58
                panic("no return value specified for CreateUser")
×
59
        }
60

61
        var r0 error
1✔
62
        if rf, ok := ret.Get(0).(func(context.Context, *model.User) error); ok {
1✔
63
                r0 = rf(ctx, u)
×
64
        } else {
1✔
65
                r0 = ret.Error(0)
1✔
66
        }
1✔
67

68
        return r0
1✔
69
}
70

71
// CreateUserInternal provides a mock function with given fields: ctx, u
72
func (_m *App) CreateUserInternal(ctx context.Context, u *model.UserInternal) error {
1✔
73
        ret := _m.Called(ctx, u)
1✔
74

1✔
75
        if len(ret) == 0 {
1✔
NEW
76
                panic("no return value specified for CreateUserInternal")
×
77
        }
78

79
        var r0 error
1✔
80
        if rf, ok := ret.Get(0).(func(context.Context, *model.UserInternal) error); ok {
1✔
81
                r0 = rf(ctx, u)
×
82
        } else {
1✔
83
                r0 = ret.Error(0)
1✔
84
        }
1✔
85

86
        return r0
1✔
87
}
88

89
// DeleteToken provides a mock function with given fields: ctx, id
90
func (_m *App) DeleteToken(ctx context.Context, id string) error {
×
91
        ret := _m.Called(ctx, id)
×
92

×
NEW
93
        if len(ret) == 0 {
×
NEW
94
                panic("no return value specified for DeleteToken")
×
95
        }
96

97
        var r0 error
×
98
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
×
99
                r0 = rf(ctx, id)
×
100
        } else {
×
101
                r0 = ret.Error(0)
×
102
        }
×
103

104
        return r0
×
105
}
106

107
// DeleteTokens provides a mock function with given fields: ctx, tenantId, userId
108
func (_m *App) DeleteTokens(ctx context.Context, tenantId string, userId string) error {
1✔
109
        ret := _m.Called(ctx, tenantId, userId)
1✔
110

1✔
111
        if len(ret) == 0 {
1✔
NEW
112
                panic("no return value specified for DeleteTokens")
×
113
        }
114

115
        var r0 error
1✔
116
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
1✔
117
                r0 = rf(ctx, tenantId, userId)
×
118
        } else {
1✔
119
                r0 = ret.Error(0)
1✔
120
        }
1✔
121

122
        return r0
1✔
123
}
124

125
// DeleteUser provides a mock function with given fields: ctx, id
126
func (_m *App) DeleteUser(ctx context.Context, id string) error {
1✔
127
        ret := _m.Called(ctx, id)
1✔
128

1✔
129
        if len(ret) == 0 {
1✔
NEW
130
                panic("no return value specified for DeleteUser")
×
131
        }
132

133
        var r0 error
1✔
134
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
1✔
135
                r0 = rf(ctx, id)
×
136
        } else {
1✔
137
                r0 = ret.Error(0)
1✔
138
        }
1✔
139

140
        return r0
1✔
141
}
142

143
// GetPersonalAccessTokens provides a mock function with given fields: ctx, userID
144
func (_m *App) GetPersonalAccessTokens(ctx context.Context, userID string) ([]model.PersonalAccessToken, error) {
1✔
145
        ret := _m.Called(ctx, userID)
1✔
146

1✔
147
        if len(ret) == 0 {
1✔
NEW
148
                panic("no return value specified for GetPersonalAccessTokens")
×
149
        }
150

151
        var r0 []model.PersonalAccessToken
1✔
152
        var r1 error
1✔
153
        if rf, ok := ret.Get(0).(func(context.Context, string) ([]model.PersonalAccessToken, error)); ok {
1✔
NEW
154
                return rf(ctx, userID)
×
NEW
155
        }
×
156
        if rf, ok := ret.Get(0).(func(context.Context, string) []model.PersonalAccessToken); ok {
1✔
157
                r0 = rf(ctx, userID)
×
158
        } else {
1✔
159
                if ret.Get(0) != nil {
2✔
160
                        r0 = ret.Get(0).([]model.PersonalAccessToken)
1✔
161
                }
1✔
162
        }
163

164
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
165
                r1 = rf(ctx, userID)
×
166
        } else {
1✔
167
                r1 = ret.Error(1)
1✔
168
        }
1✔
169

170
        return r0, r1
1✔
171
}
172

173
// GetPlanBinding provides a mock function with given fields: ctx
174
func (_m *App) GetPlanBinding(ctx context.Context) (*model.PlanBindingDetails, error) {
1✔
175
        ret := _m.Called(ctx)
1✔
176

1✔
177
        if len(ret) == 0 {
1✔
NEW
178
                panic("no return value specified for GetPlanBinding")
×
179
        }
180

181
        var r0 *model.PlanBindingDetails
1✔
182
        var r1 error
1✔
183
        if rf, ok := ret.Get(0).(func(context.Context) (*model.PlanBindingDetails, error)); ok {
1✔
NEW
184
                return rf(ctx)
×
NEW
185
        }
×
186
        if rf, ok := ret.Get(0).(func(context.Context) *model.PlanBindingDetails); ok {
1✔
187
                r0 = rf(ctx)
×
188
        } else {
1✔
189
                if ret.Get(0) != nil {
2✔
190
                        r0 = ret.Get(0).(*model.PlanBindingDetails)
1✔
191
                }
1✔
192
        }
193

194
        if rf, ok := ret.Get(1).(func(context.Context) error); ok {
1✔
UNCOV
195
                r1 = rf(ctx)
×
196
        } else {
1✔
197
                r1 = ret.Error(1)
1✔
198
        }
1✔
199

200
        return r0, r1
1✔
201
}
202

203
// GetPlans provides a mock function with given fields: ctx, skip, limit
204
func (_m *App) GetPlans(ctx context.Context, skip int, limit int) []model.Plan {
1✔
205
        ret := _m.Called(ctx, skip, limit)
1✔
206

1✔
207
        if len(ret) == 0 {
1✔
NEW
208
                panic("no return value specified for GetPlans")
×
209
        }
210

211
        var r0 []model.Plan
1✔
212
        if rf, ok := ret.Get(0).(func(context.Context, int, int) []model.Plan); ok {
1✔
213
                r0 = rf(ctx, skip, limit)
×
214
        } else {
1✔
215
                if ret.Get(0) != nil {
2✔
216
                        r0 = ret.Get(0).([]model.Plan)
1✔
217
                }
1✔
218
        }
219

220
        return r0
1✔
221
}
222

223
// GetUser provides a mock function with given fields: ctx, id
224
func (_m *App) GetUser(ctx context.Context, id string) (*model.User, error) {
1✔
225
        ret := _m.Called(ctx, id)
1✔
226

1✔
227
        if len(ret) == 0 {
1✔
NEW
228
                panic("no return value specified for GetUser")
×
229
        }
230

231
        var r0 *model.User
1✔
232
        var r1 error
1✔
233
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.User, error)); ok {
1✔
NEW
234
                return rf(ctx, id)
×
NEW
235
        }
×
236
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.User); ok {
1✔
237
                r0 = rf(ctx, id)
×
238
        } else {
1✔
239
                if ret.Get(0) != nil {
2✔
240
                        r0 = ret.Get(0).(*model.User)
1✔
241
                }
1✔
242
        }
243

244
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
245
                r1 = rf(ctx, id)
×
246
        } else {
1✔
247
                r1 = ret.Error(1)
1✔
248
        }
1✔
249

250
        return r0, r1
1✔
251
}
252

253
// GetUsers provides a mock function with given fields: ctx, fltr
254
func (_m *App) GetUsers(ctx context.Context, fltr model.UserFilter) ([]model.User, error) {
1✔
255
        ret := _m.Called(ctx, fltr)
1✔
256

1✔
257
        if len(ret) == 0 {
1✔
NEW
258
                panic("no return value specified for GetUsers")
×
259
        }
260

261
        var r0 []model.User
1✔
262
        var r1 error
1✔
263
        if rf, ok := ret.Get(0).(func(context.Context, model.UserFilter) ([]model.User, error)); ok {
1✔
NEW
264
                return rf(ctx, fltr)
×
NEW
265
        }
×
266
        if rf, ok := ret.Get(0).(func(context.Context, model.UserFilter) []model.User); ok {
1✔
267
                r0 = rf(ctx, fltr)
×
268
        } else {
1✔
269
                if ret.Get(0) != nil {
2✔
270
                        r0 = ret.Get(0).([]model.User)
1✔
271
                }
1✔
272
        }
273

274
        if rf, ok := ret.Get(1).(func(context.Context, model.UserFilter) error); ok {
1✔
UNCOV
275
                r1 = rf(ctx, fltr)
×
276
        } else {
1✔
277
                r1 = ret.Error(1)
1✔
278
        }
1✔
279

280
        return r0, r1
1✔
281
}
282

283
// HealthCheck provides a mock function with given fields: ctx
284
func (_m *App) HealthCheck(ctx context.Context) error {
1✔
285
        ret := _m.Called(ctx)
1✔
286

1✔
287
        if len(ret) == 0 {
1✔
NEW
288
                panic("no return value specified for HealthCheck")
×
289
        }
290

291
        var r0 error
1✔
292
        if rf, ok := ret.Get(0).(func(context.Context) error); ok {
1✔
293
                r0 = rf(ctx)
×
294
        } else {
1✔
295
                r0 = ret.Error(0)
1✔
296
        }
1✔
297

298
        return r0
1✔
299
}
300

301
// IssuePersonalAccessToken provides a mock function with given fields: ctx, tr
302
func (_m *App) IssuePersonalAccessToken(ctx context.Context, tr *model.TokenRequest) (string, error) {
1✔
303
        ret := _m.Called(ctx, tr)
1✔
304

1✔
305
        if len(ret) == 0 {
1✔
NEW
306
                panic("no return value specified for IssuePersonalAccessToken")
×
307
        }
308

309
        var r0 string
1✔
310
        var r1 error
1✔
311
        if rf, ok := ret.Get(0).(func(context.Context, *model.TokenRequest) (string, error)); ok {
1✔
NEW
312
                return rf(ctx, tr)
×
NEW
313
        }
×
314
        if rf, ok := ret.Get(0).(func(context.Context, *model.TokenRequest) string); ok {
1✔
315
                r0 = rf(ctx, tr)
×
316
        } else {
1✔
317
                r0 = ret.Get(0).(string)
1✔
318
        }
1✔
319

320
        if rf, ok := ret.Get(1).(func(context.Context, *model.TokenRequest) error); ok {
1✔
UNCOV
321
                r1 = rf(ctx, tr)
×
322
        } else {
1✔
323
                r1 = ret.Error(1)
1✔
324
        }
1✔
325

326
        return r0, r1
1✔
327
}
328

329
// Login provides a mock function with given fields: ctx, email, pass, options
330
func (_m *App) Login(ctx context.Context, email model.Email, pass string, options *useradm.LoginOptions) (*jwt.Token, error) {
1✔
331
        ret := _m.Called(ctx, email, pass, options)
1✔
332

1✔
333
        if len(ret) == 0 {
1✔
NEW
334
                panic("no return value specified for Login")
×
335
        }
336

337
        var r0 *jwt.Token
1✔
338
        var r1 error
1✔
339
        if rf, ok := ret.Get(0).(func(context.Context, model.Email, string, *useradm.LoginOptions) (*jwt.Token, error)); ok {
1✔
NEW
340
                return rf(ctx, email, pass, options)
×
NEW
341
        }
×
342
        if rf, ok := ret.Get(0).(func(context.Context, model.Email, string, *useradm.LoginOptions) *jwt.Token); ok {
1✔
343
                r0 = rf(ctx, email, pass, options)
×
344
        } else {
1✔
345
                if ret.Get(0) != nil {
2✔
346
                        r0 = ret.Get(0).(*jwt.Token)
1✔
347
                }
1✔
348
        }
349

350
        if rf, ok := ret.Get(1).(func(context.Context, model.Email, string, *useradm.LoginOptions) error); ok {
1✔
UNCOV
351
                r1 = rf(ctx, email, pass, options)
×
352
        } else {
1✔
353
                r1 = ret.Error(1)
1✔
354
        }
1✔
355

356
        return r0, r1
1✔
357
}
358

359
// Logout provides a mock function with given fields: ctx, token
360
func (_m *App) Logout(ctx context.Context, token *jwt.Token) error {
1✔
361
        ret := _m.Called(ctx, token)
1✔
362

1✔
363
        if len(ret) == 0 {
1✔
NEW
364
                panic("no return value specified for Logout")
×
365
        }
366

367
        var r0 error
1✔
368
        if rf, ok := ret.Get(0).(func(context.Context, *jwt.Token) error); ok {
1✔
369
                r0 = rf(ctx, token)
×
370
        } else {
1✔
371
                r0 = ret.Error(0)
1✔
372
        }
1✔
373

374
        return r0
1✔
375
}
376

377
// SetPassword provides a mock function with given fields: ctx, u
378
func (_m *App) SetPassword(ctx context.Context, u model.UserUpdate) error {
×
379
        ret := _m.Called(ctx, u)
×
380

×
NEW
381
        if len(ret) == 0 {
×
NEW
382
                panic("no return value specified for SetPassword")
×
383
        }
384

385
        var r0 error
×
386
        if rf, ok := ret.Get(0).(func(context.Context, model.UserUpdate) error); ok {
×
387
                r0 = rf(ctx, u)
×
388
        } else {
×
389
                r0 = ret.Error(0)
×
390
        }
×
391

392
        return r0
×
393
}
394

395
// SignToken provides a mock function with given fields: ctx, t
396
func (_m *App) SignToken(ctx context.Context, t *jwt.Token) (string, error) {
1✔
397
        ret := _m.Called(ctx, t)
1✔
398

1✔
399
        if len(ret) == 0 {
1✔
NEW
400
                panic("no return value specified for SignToken")
×
401
        }
402

403
        var r0 string
1✔
404
        var r1 error
1✔
405
        if rf, ok := ret.Get(0).(func(context.Context, *jwt.Token) (string, error)); ok {
1✔
NEW
406
                return rf(ctx, t)
×
NEW
407
        }
×
408
        if rf, ok := ret.Get(0).(func(context.Context, *jwt.Token) string); ok {
1✔
409
                r0 = rf(ctx, t)
×
410
        } else {
1✔
411
                r0 = ret.Get(0).(string)
1✔
412
        }
1✔
413

414
        if rf, ok := ret.Get(1).(func(context.Context, *jwt.Token) error); ok {
1✔
UNCOV
415
                r1 = rf(ctx, t)
×
416
        } else {
1✔
417
                r1 = ret.Error(1)
1✔
418
        }
1✔
419

420
        return r0, r1
1✔
421
}
422

423
// UpdateUser provides a mock function with given fields: ctx, id, u
424
func (_m *App) UpdateUser(ctx context.Context, id string, u *model.UserUpdate) error {
1✔
425
        ret := _m.Called(ctx, id, u)
1✔
426

1✔
427
        if len(ret) == 0 {
1✔
NEW
428
                panic("no return value specified for UpdateUser")
×
429
        }
430

431
        var r0 error
1✔
432
        if rf, ok := ret.Get(0).(func(context.Context, string, *model.UserUpdate) error); ok {
1✔
433
                r0 = rf(ctx, id, u)
×
434
        } else {
1✔
435
                r0 = ret.Error(0)
1✔
436
        }
1✔
437

438
        return r0
1✔
439
}
440

441
// Verify provides a mock function with given fields: ctx, token
442
func (_m *App) Verify(ctx context.Context, token *jwt.Token) error {
1✔
443
        ret := _m.Called(ctx, token)
1✔
444

1✔
445
        if len(ret) == 0 {
1✔
NEW
446
                panic("no return value specified for Verify")
×
447
        }
448

449
        var r0 error
1✔
450
        if rf, ok := ret.Get(0).(func(context.Context, *jwt.Token) error); ok {
1✔
451
                r0 = rf(ctx, token)
×
452
        } else {
1✔
453
                r0 = ret.Error(0)
1✔
454
        }
1✔
455

456
        return r0
1✔
457
}
458

459
// NewApp creates a new instance of App. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
460
// The first argument is typically a *testing.T value.
461
func NewApp(t interface {
462
        mock.TestingT
463
        Cleanup(func())
NEW
464
}) *App {
×
NEW
465
        mock := &App{}
×
NEW
466
        mock.Mock.Test(t)
×
NEW
467

×
NEW
468
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
469

NEW
470
        return mock
×
471
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc