• 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

48.83
/backend/services/deviceconnect/store/mocks/DataStore.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

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

33
// AllocateSession provides a mock function with given fields: ctx, sess
34
func (_m *DataStore) AllocateSession(ctx context.Context, sess *model.Session) error {
1✔
35
        ret := _m.Called(ctx, sess)
1✔
36

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

41
        var r0 error
1✔
42
        if rf, ok := ret.Get(0).(func(context.Context, *model.Session) error); ok {
1✔
43
                r0 = rf(ctx, sess)
×
44
        } else {
1✔
45
                r0 = ret.Error(0)
1✔
46
        }
1✔
47

48
        return r0
1✔
49
}
50

51
// Close provides a mock function with given fields:
52
func (_m *DataStore) Close() error {
×
53
        ret := _m.Called()
×
54

×
NEW
55
        if len(ret) == 0 {
×
NEW
56
                panic("no return value specified for Close")
×
57
        }
58

59
        var r0 error
×
60
        if rf, ok := ret.Get(0).(func() error); ok {
×
61
                r0 = rf()
×
62
        } else {
×
63
                r0 = ret.Error(0)
×
64
        }
×
65

66
        return r0
×
67
}
68

69
// DeleteDevice provides a mock function with given fields: ctx, tenantID, deviceID
70
func (_m *DataStore) DeleteDevice(ctx context.Context, tenantID string, deviceID string) error {
1✔
71
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
72

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

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

84
        return r0
1✔
85
}
86

87
// DeleteSession provides a mock function with given fields: ctx, sessionID
88
func (_m *DataStore) DeleteSession(ctx context.Context, sessionID string) (*model.Session, error) {
1✔
89
        ret := _m.Called(ctx, sessionID)
1✔
90

1✔
91
        if len(ret) == 0 {
1✔
NEW
92
                panic("no return value specified for DeleteSession")
×
93
        }
94

95
        var r0 *model.Session
1✔
96
        var r1 error
1✔
97
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.Session, error)); ok {
1✔
NEW
98
                return rf(ctx, sessionID)
×
NEW
99
        }
×
100
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.Session); ok {
1✔
101
                r0 = rf(ctx, sessionID)
×
102
        } else {
1✔
103
                if ret.Get(0) != nil {
2✔
104
                        r0 = ret.Get(0).(*model.Session)
1✔
105
                }
1✔
106
        }
107

108
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
1✔
UNCOV
109
                r1 = rf(ctx, sessionID)
×
110
        } else {
1✔
111
                r1 = ret.Error(1)
1✔
112
        }
1✔
113

114
        return r0, r1
1✔
115
}
116

117
// DeleteTenant provides a mock function with given fields: ctx, tenantID
118
func (_m *DataStore) DeleteTenant(ctx context.Context, tenantID string) error {
1✔
119
        ret := _m.Called(ctx, tenantID)
1✔
120

1✔
121
        if len(ret) == 0 {
1✔
NEW
122
                panic("no return value specified for DeleteTenant")
×
123
        }
124

125
        var r0 error
1✔
126
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
1✔
127
                r0 = rf(ctx, tenantID)
×
128
        } else {
1✔
129
                r0 = ret.Error(0)
1✔
130
        }
1✔
131

132
        return r0
1✔
133
}
134

135
// GetDevice provides a mock function with given fields: ctx, tenantID, deviceID
136
func (_m *DataStore) GetDevice(ctx context.Context, tenantID string, deviceID string) (*model.Device, error) {
1✔
137
        ret := _m.Called(ctx, tenantID, deviceID)
1✔
138

1✔
139
        if len(ret) == 0 {
1✔
NEW
140
                panic("no return value specified for GetDevice")
×
141
        }
142

143
        var r0 *model.Device
1✔
144
        var r1 error
1✔
145
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*model.Device, error)); ok {
1✔
NEW
146
                return rf(ctx, tenantID, deviceID)
×
NEW
147
        }
×
148
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *model.Device); ok {
1✔
149
                r0 = rf(ctx, tenantID, deviceID)
×
150
        } else {
1✔
151
                if ret.Get(0) != nil {
2✔
152
                        r0 = ret.Get(0).(*model.Device)
1✔
153
                }
1✔
154
        }
155

156
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
157
                r1 = rf(ctx, tenantID, deviceID)
×
158
        } else {
1✔
159
                r1 = ret.Error(1)
1✔
160
        }
1✔
161

162
        return r0, r1
1✔
163
}
164

165
// GetSession provides a mock function with given fields: ctx, sessionID
166
func (_m *DataStore) GetSession(ctx context.Context, sessionID string) (*model.Session, error) {
×
167
        ret := _m.Called(ctx, sessionID)
×
168

×
NEW
169
        if len(ret) == 0 {
×
NEW
170
                panic("no return value specified for GetSession")
×
171
        }
172

173
        var r0 *model.Session
×
NEW
174
        var r1 error
×
NEW
175
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.Session, error)); ok {
×
NEW
176
                return rf(ctx, sessionID)
×
NEW
177
        }
×
178
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.Session); ok {
×
179
                r0 = rf(ctx, sessionID)
×
180
        } else {
×
181
                if ret.Get(0) != nil {
×
182
                        r0 = ret.Get(0).(*model.Session)
×
183
                }
×
184
        }
185

186
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
×
187
                r1 = rf(ctx, sessionID)
×
188
        } else {
×
189
                r1 = ret.Error(1)
×
190
        }
×
191

192
        return r0, r1
×
193
}
194

195
// InsertControlRecording provides a mock function with given fields: ctx, sessionID, sessionBytes
196
func (_m *DataStore) InsertControlRecording(ctx context.Context, sessionID string, sessionBytes []byte) error {
×
197
        ret := _m.Called(ctx, sessionID, sessionBytes)
×
198

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

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

210
        return r0
×
211
}
212

213
// InsertSessionRecording provides a mock function with given fields: ctx, sessionID, sessionBytes
214
func (_m *DataStore) InsertSessionRecording(ctx context.Context, sessionID string, sessionBytes []byte) error {
1✔
215
        ret := _m.Called(ctx, sessionID, sessionBytes)
1✔
216

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

221
        var r0 error
1✔
222
        if rf, ok := ret.Get(0).(func(context.Context, string, []byte) error); ok {
1✔
223
                r0 = rf(ctx, sessionID, sessionBytes)
×
224
        } else {
1✔
225
                r0 = ret.Error(0)
1✔
226
        }
1✔
227

228
        return r0
1✔
229
}
230

231
// Ping provides a mock function with given fields: ctx
232
func (_m *DataStore) Ping(ctx context.Context) error {
1✔
233
        ret := _m.Called(ctx)
1✔
234

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

239
        var r0 error
1✔
240
        if rf, ok := ret.Get(0).(func(context.Context) error); ok {
1✔
241
                r0 = rf(ctx)
×
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, deviceID
250
func (_m *DataStore) ProvisionDevice(ctx context.Context, tenantID string, deviceID string) error {
1✔
251
        ret := _m.Called(ctx, tenantID, deviceID)
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, string) error); ok {
1✔
259
                r0 = rf(ctx, tenantID, deviceID)
×
260
        } else {
1✔
261
                r0 = ret.Error(0)
1✔
262
        }
1✔
263

264
        return r0
1✔
265
}
266

267
// SetDeviceConnected provides a mock function with given fields: ctx, tenantID, deviceID
268
func (_m *DataStore) SetDeviceConnected(ctx context.Context, tenantID string, deviceID string) (int64, error) {
×
269
        ret := _m.Called(ctx, tenantID, deviceID)
×
270

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

275
        var r0 int64
×
NEW
276
        var r1 error
×
NEW
277
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (int64, error)); ok {
×
NEW
278
                return rf(ctx, tenantID, deviceID)
×
NEW
279
        }
×
280
        if rf, ok := ret.Get(0).(func(context.Context, string, string) int64); ok {
×
281
                r0 = rf(ctx, tenantID, deviceID)
×
282
        } else {
×
283
                r0 = ret.Get(0).(int64)
×
284
        }
×
285

286
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
×
287
                r1 = rf(ctx, tenantID, deviceID)
×
288
        } else {
×
289
                r1 = ret.Error(1)
×
290
        }
×
291

292
        return r0, r1
×
293
}
294

295
// SetDeviceDisconnected provides a mock function with given fields: ctx, tenantID, deviceID, version
296
func (_m *DataStore) SetDeviceDisconnected(ctx context.Context, tenantID string, deviceID string, version int64) error {
×
297
        ret := _m.Called(ctx, tenantID, deviceID, version)
×
298

×
NEW
299
        if len(ret) == 0 {
×
NEW
300
                panic("no return value specified for SetDeviceDisconnected")
×
301
        }
302

303
        var r0 error
×
304
        if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) error); ok {
×
305
                r0 = rf(ctx, tenantID, deviceID, version)
×
306
        } else {
×
307
                r0 = ret.Error(0)
×
308
        }
×
309

310
        return r0
×
311
}
312

313
// WriteSessionRecords provides a mock function with given fields: ctx, sessionID, w
314
func (_m *DataStore) WriteSessionRecords(ctx context.Context, sessionID string, w io.Writer) error {
1✔
315
        ret := _m.Called(ctx, sessionID, w)
1✔
316

1✔
317
        if len(ret) == 0 {
1✔
NEW
318
                panic("no return value specified for WriteSessionRecords")
×
319
        }
320

321
        var r0 error
1✔
322
        if rf, ok := ret.Get(0).(func(context.Context, string, io.Writer) error); ok {
1✔
323
                r0 = rf(ctx, sessionID, w)
×
324
        } else {
1✔
325
                r0 = ret.Error(0)
1✔
326
        }
1✔
327

328
        return r0
1✔
329
}
330

331
// NewDataStore creates a new instance of DataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
332
// The first argument is typically a *testing.T value.
333
func NewDataStore(t interface {
334
        mock.TestingT
335
        Cleanup(func())
NEW
336
}) *DataStore {
×
NEW
337
        mock := &DataStore{}
×
NEW
338
        mock.Mock.Test(t)
×
NEW
339

×
NEW
340
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
341

NEW
342
        return mock
×
343
}
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