• 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

73.33
/backend/services/deviceconnect/app/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
        io "io"
22

23
        mock "github.com/stretchr/testify/mock"
24

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

27
        time "time"
28
)
29

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

35
// DeleteDevice provides a mock function with given fields: ctx, tenantID, deviceID
36
func (_m *App) DeleteDevice(ctx context.Context, tenantID string, deviceID string) error {
1✔
37
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
38

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

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

50
        return r0
1✔
51
}
52

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

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

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

68
        return r0
1✔
69
}
70

71
// DownloadFile provides a mock function with given fields: ctx, userID, deviceID, path
72
func (_m *App) DownloadFile(ctx context.Context, userID string, deviceID string, path string) error {
1✔
73
        ret := _m.Called(ctx, userID, deviceID, path)
1✔
74

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

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

86
        return r0
1✔
87
}
88

89
// FreeUserSession provides a mock function with given fields: ctx, sessionID, sessionTypes
90
func (_m *App) FreeUserSession(ctx context.Context, sessionID string, sessionTypes []string) error {
1✔
91
        ret := _m.Called(ctx, sessionID, sessionTypes)
1✔
92

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

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

104
        return r0
1✔
105
}
106

107
// GetControlRecorder provides a mock function with given fields: ctx, sessionID
108
func (_m *App) GetControlRecorder(ctx context.Context, sessionID string) io.Writer {
1✔
109
        ret := _m.Called(ctx, sessionID)
1✔
110

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

115
        var r0 io.Writer
1✔
116
        if rf, ok := ret.Get(0).(func(context.Context, string) io.Writer); ok {
1✔
117
                r0 = rf(ctx, sessionID)
×
118
        } else {
1✔
119
                if ret.Get(0) != nil {
1✔
120
                        r0 = ret.Get(0).(io.Writer)
×
121
                }
×
122
        }
123

124
        return r0
1✔
125
}
126

127
// GetDevice provides a mock function with given fields: ctx, tenantID, deviceID
128
func (_m *App) GetDevice(ctx context.Context, tenantID string, deviceID string) (*model.Device, error) {
1✔
129
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
130

1✔
131
        if len(ret) == 0 {
1✔
NEW
132
                panic("no return value specified for GetDevice")
×
133
        }
134

135
        var r0 *model.Device
1✔
136
        var r1 error
1✔
137
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*model.Device, error)); ok {
1✔
NEW
138
                return rf(ctx, tenantID, deviceID)
×
NEW
139
        }
×
140
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *model.Device); ok {
1✔
141
                r0 = rf(ctx, tenantID, deviceID)
×
142
        } else {
1✔
143
                if ret.Get(0) != nil {
2✔
144
                        r0 = ret.Get(0).(*model.Device)
1✔
145
                }
1✔
146
        }
147

148
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
149
                r1 = rf(ctx, tenantID, deviceID)
×
150
        } else {
1✔
151
                r1 = ret.Error(1)
1✔
152
        }
1✔
153

154
        return r0, r1
1✔
155
}
156

157
// GetRecorder provides a mock function with given fields: ctx, sessionID
158
func (_m *App) GetRecorder(ctx context.Context, sessionID string) io.Writer {
1✔
159
        ret := _m.Called(ctx, sessionID)
1✔
160

1✔
161
        if len(ret) == 0 {
1✔
NEW
162
                panic("no return value specified for GetRecorder")
×
163
        }
164

165
        var r0 io.Writer
1✔
166
        if rf, ok := ret.Get(0).(func(context.Context, string) io.Writer); ok {
1✔
167
                r0 = rf(ctx, sessionID)
×
168
        } else {
1✔
169
                if ret.Get(0) != nil {
2✔
170
                        r0 = ret.Get(0).(io.Writer)
1✔
171
                }
1✔
172
        }
173

174
        return r0
1✔
175
}
176

177
// GetSessionRecording provides a mock function with given fields: ctx, id, w
178
func (_m *App) GetSessionRecording(ctx context.Context, id string, w io.Writer) error {
1✔
179
        ret := _m.Called(ctx, id, w)
1✔
180

1✔
181
        if len(ret) == 0 {
1✔
NEW
182
                panic("no return value specified for GetSessionRecording")
×
183
        }
184

185
        var r0 error
1✔
186
        if rf, ok := ret.Get(0).(func(context.Context, string, io.Writer) error); ok {
1✔
187
                r0 = rf(ctx, id, w)
×
188
        } else {
1✔
189
                r0 = ret.Error(0)
1✔
190
        }
1✔
191

192
        return r0
1✔
193
}
194

195
// HealthCheck provides a mock function with given fields: ctx
196
func (_m *App) HealthCheck(ctx context.Context) error {
1✔
197
        ret := _m.Called(ctx)
1✔
198

1✔
199
        if len(ret) == 0 {
1✔
NEW
200
                panic("no return value specified for HealthCheck")
×
201
        }
202

203
        var r0 error
1✔
204
        if rf, ok := ret.Get(0).(func(context.Context) error); ok {
1✔
205
                r0 = rf(ctx)
×
206
        } else {
1✔
207
                r0 = ret.Error(0)
1✔
208
        }
1✔
209

210
        return r0
1✔
211
}
212

213
// LogUserSession provides a mock function with given fields: ctx, sess, sessionType
214
func (_m *App) LogUserSession(ctx context.Context, sess *model.Session, sessionType string) error {
1✔
215
        ret := _m.Called(ctx, sess, sessionType)
1✔
216

1✔
217
        if len(ret) == 0 {
1✔
NEW
218
                panic("no return value specified for LogUserSession")
×
219
        }
220

221
        var r0 error
1✔
222
        if rf, ok := ret.Get(0).(func(context.Context, *model.Session, string) error); ok {
1✔
223
                r0 = rf(ctx, sess, sessionType)
×
224
        } else {
1✔
225
                r0 = ret.Error(0)
1✔
226
        }
1✔
227

228
        return r0
1✔
229
}
230

231
// PrepareUserSession provides a mock function with given fields: ctx, sess
232
func (_m *App) PrepareUserSession(ctx context.Context, sess *model.Session) error {
1✔
233
        ret := _m.Called(ctx, sess)
1✔
234

1✔
235
        if len(ret) == 0 {
1✔
NEW
236
                panic("no return value specified for PrepareUserSession")
×
237
        }
238

239
        var r0 error
1✔
240
        if rf, ok := ret.Get(0).(func(context.Context, *model.Session) error); ok {
1✔
241
                r0 = rf(ctx, sess)
×
242
        } else {
1✔
243
                r0 = ret.Error(0)
1✔
244
        }
1✔
245

246
        return r0
1✔
247
}
248

249
// ProvisionDevice provides a mock function with given fields: ctx, tenantID, device
250
func (_m *App) ProvisionDevice(ctx context.Context, tenantID string, device *model.Device) error {
1✔
251
        ret := _m.Called(ctx, tenantID, device)
1✔
252

1✔
253
        if len(ret) == 0 {
1✔
NEW
254
                panic("no return value specified for ProvisionDevice")
×
255
        }
256

257
        var r0 error
1✔
258
        if rf, ok := ret.Get(0).(func(context.Context, string, *model.Device) error); ok {
1✔
259
                r0 = rf(ctx, tenantID, device)
×
260
        } else {
1✔
261
                r0 = ret.Error(0)
1✔
262
        }
1✔
263

264
        return r0
1✔
265
}
266

267
// RegisterShutdownCancel provides a mock function with given fields: _a0
268
func (_m *App) RegisterShutdownCancel(_a0 context.CancelFunc) uint32 {
1✔
269
        ret := _m.Called(_a0)
1✔
270

1✔
271
        if len(ret) == 0 {
1✔
NEW
272
                panic("no return value specified for RegisterShutdownCancel")
×
273
        }
274

275
        var r0 uint32
1✔
276
        if rf, ok := ret.Get(0).(func(context.CancelFunc) uint32); ok {
1✔
277
                r0 = rf(_a0)
×
278
        } else {
1✔
279
                r0 = ret.Get(0).(uint32)
1✔
280
        }
1✔
281

282
        return r0
1✔
283
}
284

285
// SaveSessionRecording provides a mock function with given fields: ctx, id, sessionBytes
286
func (_m *App) SaveSessionRecording(ctx context.Context, id string, sessionBytes []byte) error {
×
287
        ret := _m.Called(ctx, id, sessionBytes)
×
288

×
NEW
289
        if len(ret) == 0 {
×
NEW
290
                panic("no return value specified for SaveSessionRecording")
×
291
        }
292

293
        var r0 error
×
294
        if rf, ok := ret.Get(0).(func(context.Context, string, []byte) error); ok {
×
295
                r0 = rf(ctx, id, sessionBytes)
×
296
        } else {
×
297
                r0 = ret.Error(0)
×
298
        }
×
299

300
        return r0
×
301
}
302

303
// SetDeviceConnected provides a mock function with given fields: ctx, tenantID, deviceID
304
func (_m *App) SetDeviceConnected(ctx context.Context, tenantID string, deviceID string) (int64, error) {
1✔
305
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
306

1✔
307
        if len(ret) == 0 {
1✔
NEW
308
                panic("no return value specified for SetDeviceConnected")
×
309
        }
310

311
        var r0 int64
1✔
312
        var r1 error
1✔
313
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (int64, error)); ok {
1✔
NEW
314
                return rf(ctx, tenantID, deviceID)
×
NEW
315
        }
×
316
        if rf, ok := ret.Get(0).(func(context.Context, string, string) int64); ok {
1✔
317
                r0 = rf(ctx, tenantID, deviceID)
×
318
        } else {
1✔
319
                r0 = ret.Get(0).(int64)
1✔
320
        }
1✔
321

322
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
323
                r1 = rf(ctx, tenantID, deviceID)
×
324
        } else {
1✔
325
                r1 = ret.Error(1)
1✔
326
        }
1✔
327

328
        return r0, r1
1✔
329
}
330

331
// SetDeviceDisconnected provides a mock function with given fields: ctx, tenantID, deviceID, version
332
func (_m *App) SetDeviceDisconnected(ctx context.Context, tenantID string, deviceID string, version int64) error {
1✔
333
        ret := _m.Called(ctx, tenantID, deviceID, version)
1✔
334

1✔
335
        if len(ret) == 0 {
1✔
NEW
336
                panic("no return value specified for SetDeviceDisconnected")
×
337
        }
338

339
        var r0 error
1✔
340
        if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) error); ok {
1✔
341
                r0 = rf(ctx, tenantID, deviceID, version)
×
342
        } else {
1✔
343
                r0 = ret.Error(0)
1✔
344
        }
1✔
345

346
        return r0
1✔
347
}
348

349
// Shutdown provides a mock function with given fields: timeout
350
func (_m *App) Shutdown(timeout time.Duration) {
×
351
        _m.Called(timeout)
×
352
}
×
353

354
// ShutdownDone provides a mock function with given fields:
355
func (_m *App) ShutdownDone() {
×
356
        _m.Called()
×
357
}
×
358

359
// UnregisterShutdownCancel provides a mock function with given fields: _a0
360
func (_m *App) UnregisterShutdownCancel(_a0 uint32) {
1✔
361
        _m.Called(_a0)
1✔
362
}
1✔
363

364
// UploadFile provides a mock function with given fields: ctx, userID, deviceID, path
365
func (_m *App) UploadFile(ctx context.Context, userID string, deviceID string, path string) error {
1✔
366
        ret := _m.Called(ctx, userID, deviceID, path)
1✔
367

1✔
368
        if len(ret) == 0 {
1✔
NEW
369
                panic("no return value specified for UploadFile")
×
370
        }
371

372
        var r0 error
1✔
373
        if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok {
1✔
374
                r0 = rf(ctx, userID, deviceID, path)
×
375
        } else {
1✔
376
                r0 = ret.Error(0)
1✔
377
        }
1✔
378

379
        return r0
1✔
380
}
381

382
// 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.
383
// The first argument is typically a *testing.T value.
384
func NewApp(t interface {
385
        mock.TestingT
386
        Cleanup(func())
NEW
387
}) *App {
×
NEW
388
        mock := &App{}
×
NEW
389
        mock.Mock.Test(t)
×
NEW
390

×
NEW
391
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
392

NEW
393
        return mock
×
394
}
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