• 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

74.07
/backend/services/deviceauth/devauth/mocks/App.go
1
// Copyright 2024 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
        mock "github.com/stretchr/testify/mock"
23

24
        model "github.com/mendersoftware/mender-server/services/deviceauth/model"
25
)
26

27
// App is an autogenerated mock type for the App type
28
type App struct {
29
        mock.Mock
30
}
31

32
// AcceptDeviceAuth provides a mock function with given fields: ctx, dev_id, auth_id
33
func (_m *App) AcceptDeviceAuth(ctx context.Context, dev_id string, auth_id string) error {
1✔
34
        ret := _m.Called(ctx, dev_id, auth_id)
1✔
35

1✔
36
        if len(ret) == 0 {
1✔
NEW
37
                panic("no return value specified for AcceptDeviceAuth")
×
38
        }
39

40
        var r0 error
1✔
41
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
2✔
42
                r0 = rf(ctx, dev_id, auth_id)
1✔
43
        } else {
1✔
44
                r0 = ret.Error(0)
×
45
        }
×
46

47
        return r0
1✔
48
}
49

50
// DecommissionDevice provides a mock function with given fields: ctx, dev_id
51
func (_m *App) DecommissionDevice(ctx context.Context, dev_id string) error {
1✔
52
        ret := _m.Called(ctx, dev_id)
1✔
53

1✔
54
        if len(ret) == 0 {
1✔
NEW
55
                panic("no return value specified for DecommissionDevice")
×
56
        }
57

58
        var r0 error
1✔
59
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
1✔
60
                r0 = rf(ctx, dev_id)
×
61
        } else {
1✔
62
                r0 = ret.Error(0)
1✔
63
        }
1✔
64

65
        return r0
1✔
66
}
67

68
// DeleteAuthSet provides a mock function with given fields: ctx, dev_id, auth_id
69
func (_m *App) DeleteAuthSet(ctx context.Context, dev_id string, auth_id string) error {
1✔
70
        ret := _m.Called(ctx, dev_id, auth_id)
1✔
71

1✔
72
        if len(ret) == 0 {
1✔
NEW
73
                panic("no return value specified for DeleteAuthSet")
×
74
        }
75

76
        var r0 error
1✔
77
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
1✔
78
                r0 = rf(ctx, dev_id, auth_id)
×
79
        } else {
1✔
80
                r0 = ret.Error(0)
1✔
81
        }
1✔
82

83
        return r0
1✔
84
}
85

86
// DeleteDevice provides a mock function with given fields: ctx, dev_id
87
func (_m *App) DeleteDevice(ctx context.Context, dev_id string) error {
×
88
        ret := _m.Called(ctx, dev_id)
×
89

×
NEW
90
        if len(ret) == 0 {
×
NEW
91
                panic("no return value specified for DeleteDevice")
×
92
        }
93

94
        var r0 error
×
95
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
×
96
                r0 = rf(ctx, dev_id)
×
97
        } else {
×
98
                r0 = ret.Error(0)
×
99
        }
×
100

101
        return r0
×
102
}
103

104
// DeleteTenantLimit provides a mock function with given fields: ctx, tenant_id, limit
105
func (_m *App) DeleteTenantLimit(ctx context.Context, tenant_id string, limit string) error {
1✔
106
        ret := _m.Called(ctx, tenant_id, limit)
1✔
107

1✔
108
        if len(ret) == 0 {
1✔
NEW
109
                panic("no return value specified for DeleteTenantLimit")
×
110
        }
111

112
        var r0 error
1✔
113
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
1✔
114
                r0 = rf(ctx, tenant_id, limit)
×
115
        } else {
1✔
116
                r0 = ret.Error(0)
1✔
117
        }
1✔
118

119
        return r0
1✔
120
}
121

122
// DeleteTokens provides a mock function with given fields: ctx, tenantID, deviceID
123
func (_m *App) DeleteTokens(ctx context.Context, tenantID string, deviceID string) error {
1✔
124
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
125

1✔
126
        if len(ret) == 0 {
1✔
NEW
127
                panic("no return value specified for DeleteTokens")
×
128
        }
129

130
        var r0 error
1✔
131
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
1✔
132
                r0 = rf(ctx, tenantID, deviceID)
×
133
        } else {
1✔
134
                r0 = ret.Error(0)
1✔
135
        }
1✔
136

137
        return r0
1✔
138
}
139

140
// GetDevCountByStatus provides a mock function with given fields: ctx, status
141
func (_m *App) GetDevCountByStatus(ctx context.Context, status string) (int, error) {
1✔
142
        ret := _m.Called(ctx, status)
1✔
143

1✔
144
        if len(ret) == 0 {
1✔
NEW
145
                panic("no return value specified for GetDevCountByStatus")
×
146
        }
147

148
        var r0 int
1✔
149
        var r1 error
1✔
150
        if rf, ok := ret.Get(0).(func(context.Context, string) (int, error)); ok {
1✔
NEW
151
                return rf(ctx, status)
×
NEW
152
        }
×
153
        if rf, ok := ret.Get(0).(func(context.Context, string) int); ok {
1✔
154
                r0 = rf(ctx, status)
×
155
        } else {
1✔
156
                r0 = ret.Get(0).(int)
1✔
157
        }
1✔
158

159
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
160
                r1 = rf(ctx, status)
×
161
        } else {
1✔
162
                r1 = ret.Error(1)
1✔
163
        }
1✔
164

165
        return r0, r1
1✔
166
}
167

168
// GetDevice provides a mock function with given fields: ctx, dev_id
169
func (_m *App) GetDevice(ctx context.Context, dev_id string) (*model.Device, error) {
1✔
170
        ret := _m.Called(ctx, dev_id)
1✔
171

1✔
172
        if len(ret) == 0 {
1✔
NEW
173
                panic("no return value specified for GetDevice")
×
174
        }
175

176
        var r0 *model.Device
1✔
177
        var r1 error
1✔
178
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.Device, error)); ok {
1✔
NEW
179
                return rf(ctx, dev_id)
×
NEW
180
        }
×
181
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.Device); ok {
1✔
182
                r0 = rf(ctx, dev_id)
×
183
        } else {
1✔
184
                if ret.Get(0) != nil {
2✔
185
                        r0 = ret.Get(0).(*model.Device)
1✔
186
                }
1✔
187
        }
188

189
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
190
                r1 = rf(ctx, dev_id)
×
191
        } else {
1✔
192
                r1 = ret.Error(1)
1✔
193
        }
1✔
194

195
        return r0, r1
1✔
196
}
197

198
// GetDevices provides a mock function with given fields: ctx, skip, limit, filter
199
func (_m *App) GetDevices(ctx context.Context, skip uint, limit uint, filter model.DeviceFilter) ([]model.Device, error) {
1✔
200
        ret := _m.Called(ctx, skip, limit, filter)
1✔
201

1✔
202
        if len(ret) == 0 {
1✔
NEW
203
                panic("no return value specified for GetDevices")
×
204
        }
205

206
        var r0 []model.Device
1✔
207
        var r1 error
1✔
208
        if rf, ok := ret.Get(0).(func(context.Context, uint, uint, model.DeviceFilter) ([]model.Device, error)); ok {
1✔
NEW
209
                return rf(ctx, skip, limit, filter)
×
NEW
210
        }
×
211
        if rf, ok := ret.Get(0).(func(context.Context, uint, uint, model.DeviceFilter) []model.Device); ok {
1✔
212
                r0 = rf(ctx, skip, limit, filter)
×
213
        } else {
1✔
214
                if ret.Get(0) != nil {
2✔
215
                        r0 = ret.Get(0).([]model.Device)
1✔
216
                }
1✔
217
        }
218

219
        if rf, ok := ret.Get(1).(func(context.Context, uint, uint, model.DeviceFilter) error); ok {
1✔
UNCOV
220
                r1 = rf(ctx, skip, limit, filter)
×
221
        } else {
1✔
222
                r1 = ret.Error(1)
1✔
223
        }
1✔
224

225
        return r0, r1
1✔
226
}
227

228
// GetLimit provides a mock function with given fields: ctx, name
229
func (_m *App) GetLimit(ctx context.Context, name string) (*model.Limit, error) {
1✔
230
        ret := _m.Called(ctx, name)
1✔
231

1✔
232
        if len(ret) == 0 {
1✔
NEW
233
                panic("no return value specified for GetLimit")
×
234
        }
235

236
        var r0 *model.Limit
1✔
237
        var r1 error
1✔
238
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.Limit, error)); ok {
1✔
NEW
239
                return rf(ctx, name)
×
NEW
240
        }
×
241
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.Limit); ok {
1✔
242
                r0 = rf(ctx, name)
×
243
        } else {
1✔
244
                if ret.Get(0) != nil {
2✔
245
                        r0 = ret.Get(0).(*model.Limit)
1✔
246
                }
1✔
247
        }
248

249
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
250
                r1 = rf(ctx, name)
×
251
        } else {
1✔
252
                r1 = ret.Error(1)
1✔
253
        }
1✔
254

255
        return r0, r1
1✔
256
}
257

258
// GetTenantDeviceStatus provides a mock function with given fields: ctx, tenantId, deviceId
259
func (_m *App) GetTenantDeviceStatus(ctx context.Context, tenantId string, deviceId string) (*model.Status, error) {
1✔
260
        ret := _m.Called(ctx, tenantId, deviceId)
1✔
261

1✔
262
        if len(ret) == 0 {
1✔
NEW
263
                panic("no return value specified for GetTenantDeviceStatus")
×
264
        }
265

266
        var r0 *model.Status
1✔
267
        var r1 error
1✔
268
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*model.Status, error)); ok {
1✔
NEW
269
                return rf(ctx, tenantId, deviceId)
×
NEW
270
        }
×
271
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *model.Status); ok {
1✔
272
                r0 = rf(ctx, tenantId, deviceId)
×
273
        } else {
1✔
274
                if ret.Get(0) != nil {
2✔
275
                        r0 = ret.Get(0).(*model.Status)
1✔
276
                }
1✔
277
        }
278

279
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
280
                r1 = rf(ctx, tenantId, deviceId)
×
281
        } else {
1✔
282
                r1 = ret.Error(1)
1✔
283
        }
1✔
284

285
        return r0, r1
1✔
286
}
287

288
// GetTenantLimit provides a mock function with given fields: ctx, name, tenant_id
289
func (_m *App) GetTenantLimit(ctx context.Context, name string, tenant_id string) (*model.Limit, error) {
1✔
290
        ret := _m.Called(ctx, name, tenant_id)
1✔
291

1✔
292
        if len(ret) == 0 {
1✔
NEW
293
                panic("no return value specified for GetTenantLimit")
×
294
        }
295

296
        var r0 *model.Limit
1✔
297
        var r1 error
1✔
298
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*model.Limit, error)); ok {
1✔
NEW
299
                return rf(ctx, name, tenant_id)
×
NEW
300
        }
×
301
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *model.Limit); ok {
1✔
302
                r0 = rf(ctx, name, tenant_id)
×
303
        } else {
1✔
304
                if ret.Get(0) != nil {
2✔
305
                        r0 = ret.Get(0).(*model.Limit)
1✔
306
                }
1✔
307
        }
308

309
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
310
                r1 = rf(ctx, name, tenant_id)
×
311
        } else {
1✔
312
                r1 = ret.Error(1)
1✔
313
        }
1✔
314

315
        return r0, r1
1✔
316
}
317

318
// HealthCheck provides a mock function with given fields: ctx
319
func (_m *App) HealthCheck(ctx context.Context) error {
1✔
320
        ret := _m.Called(ctx)
1✔
321

1✔
322
        if len(ret) == 0 {
1✔
NEW
323
                panic("no return value specified for HealthCheck")
×
324
        }
325

326
        var r0 error
1✔
327
        if rf, ok := ret.Get(0).(func(context.Context) error); ok {
1✔
328
                r0 = rf(ctx)
×
329
        } else {
1✔
330
                r0 = ret.Error(0)
1✔
331
        }
1✔
332

333
        return r0
1✔
334
}
335

336
// PreauthorizeDevice provides a mock function with given fields: ctx, req
337
func (_m *App) PreauthorizeDevice(ctx context.Context, req *model.PreAuthReq) (*model.Device, error) {
1✔
338
        ret := _m.Called(ctx, req)
1✔
339

1✔
340
        if len(ret) == 0 {
1✔
NEW
341
                panic("no return value specified for PreauthorizeDevice")
×
342
        }
343

344
        var r0 *model.Device
1✔
345
        var r1 error
1✔
346
        if rf, ok := ret.Get(0).(func(context.Context, *model.PreAuthReq) (*model.Device, error)); ok {
1✔
NEW
347
                return rf(ctx, req)
×
NEW
348
        }
×
349
        if rf, ok := ret.Get(0).(func(context.Context, *model.PreAuthReq) *model.Device); ok {
1✔
350
                r0 = rf(ctx, req)
×
351
        } else {
1✔
352
                if ret.Get(0) != nil {
2✔
353
                        r0 = ret.Get(0).(*model.Device)
1✔
354
                }
1✔
355
        }
356

357
        if rf, ok := ret.Get(1).(func(context.Context, *model.PreAuthReq) error); ok {
1✔
UNCOV
358
                r1 = rf(ctx, req)
×
359
        } else {
1✔
360
                r1 = ret.Error(1)
1✔
361
        }
1✔
362

363
        return r0, r1
1✔
364
}
365

366
// RejectDeviceAuth provides a mock function with given fields: ctx, dev_id, auth_id
367
func (_m *App) RejectDeviceAuth(ctx context.Context, dev_id string, auth_id string) error {
1✔
368
        ret := _m.Called(ctx, dev_id, auth_id)
1✔
369

1✔
370
        if len(ret) == 0 {
1✔
NEW
371
                panic("no return value specified for RejectDeviceAuth")
×
372
        }
373

374
        var r0 error
1✔
375
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
2✔
376
                r0 = rf(ctx, dev_id, auth_id)
1✔
377
        } else {
1✔
378
                r0 = ret.Error(0)
×
379
        }
×
380

381
        return r0
1✔
382
}
383

384
// ResetDeviceAuth provides a mock function with given fields: ctx, dev_id, auth_id
385
func (_m *App) ResetDeviceAuth(ctx context.Context, dev_id string, auth_id string) error {
1✔
386
        ret := _m.Called(ctx, dev_id, auth_id)
1✔
387

1✔
388
        if len(ret) == 0 {
1✔
NEW
389
                panic("no return value specified for ResetDeviceAuth")
×
390
        }
391

392
        var r0 error
1✔
393
        if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
2✔
394
                r0 = rf(ctx, dev_id, auth_id)
1✔
395
        } else {
1✔
396
                r0 = ret.Error(0)
×
397
        }
×
398

399
        return r0
1✔
400
}
401

402
// RevokeToken provides a mock function with given fields: ctx, tokenID
403
func (_m *App) RevokeToken(ctx context.Context, tokenID string) error {
1✔
404
        ret := _m.Called(ctx, tokenID)
1✔
405

1✔
406
        if len(ret) == 0 {
1✔
NEW
407
                panic("no return value specified for RevokeToken")
×
408
        }
409

410
        var r0 error
1✔
411
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
1✔
412
                r0 = rf(ctx, tokenID)
×
413
        } else {
1✔
414
                r0 = ret.Error(0)
1✔
415
        }
1✔
416

417
        return r0
1✔
418
}
419

420
// SetTenantLimit provides a mock function with given fields: ctx, tenant_id, limit
421
func (_m *App) SetTenantLimit(ctx context.Context, tenant_id string, limit model.Limit) error {
1✔
422
        ret := _m.Called(ctx, tenant_id, limit)
1✔
423

1✔
424
        if len(ret) == 0 {
1✔
NEW
425
                panic("no return value specified for SetTenantLimit")
×
426
        }
427

428
        var r0 error
1✔
429
        if rf, ok := ret.Get(0).(func(context.Context, string, model.Limit) error); ok {
1✔
430
                r0 = rf(ctx, tenant_id, limit)
×
431
        } else {
1✔
432
                r0 = ret.Error(0)
1✔
433
        }
1✔
434

435
        return r0
1✔
436
}
437

438
// SubmitAuthRequest provides a mock function with given fields: ctx, r
439
func (_m *App) SubmitAuthRequest(ctx context.Context, r *model.AuthReq) (string, error) {
1✔
440
        ret := _m.Called(ctx, r)
1✔
441

1✔
442
        if len(ret) == 0 {
1✔
NEW
443
                panic("no return value specified for SubmitAuthRequest")
×
444
        }
445

446
        var r0 string
1✔
447
        var r1 error
1✔
448
        if rf, ok := ret.Get(0).(func(context.Context, *model.AuthReq) (string, error)); ok {
1✔
NEW
449
                return rf(ctx, r)
×
NEW
450
        }
×
451
        if rf, ok := ret.Get(0).(func(context.Context, *model.AuthReq) string); ok {
2✔
452
                r0 = rf(ctx, r)
1✔
453
        } else {
1✔
454
                r0 = ret.Get(0).(string)
×
455
        }
×
456

457
        if rf, ok := ret.Get(1).(func(context.Context, *model.AuthReq) error); ok {
1✔
UNCOV
458
                r1 = rf(ctx, r)
×
459
        } else {
1✔
460
                r1 = ret.Error(1)
1✔
461
        }
1✔
462

463
        return r0, r1
1✔
464
}
465

466
// VerifyToken provides a mock function with given fields: ctx, token
467
func (_m *App) VerifyToken(ctx context.Context, token string) error {
1✔
468
        ret := _m.Called(ctx, token)
1✔
469

1✔
470
        if len(ret) == 0 {
1✔
NEW
471
                panic("no return value specified for VerifyToken")
×
472
        }
473

474
        var r0 error
1✔
475
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
1✔
476
                r0 = rf(ctx, token)
×
477
        } else {
1✔
478
                r0 = ret.Error(0)
1✔
479
        }
1✔
480

481
        return r0
1✔
482
}
483

484
// 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.
485
// The first argument is typically a *testing.T value.
486
func NewApp(t interface {
487
        mock.TestingT
488
        Cleanup(func())
NEW
489
}) *App {
×
NEW
490
        mock := &App{}
×
NEW
491
        mock.Mock.Test(t)
×
NEW
492

×
NEW
493
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
494

NEW
495
        return mock
×
496
}
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