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

mendersoftware / mender-server / 1769701362

15 Apr 2025 01:54PM UTC coverage: 65.264%. First build
1769701362

Pull #202

gitlab-ci

alfrunes
test: Fix deviceauth.cache tests after changing client initialization

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #202: MEN-7733: Rate limits for devices APIs

144 of 389 new or added lines in 8 files covered. (37.02%)

31803 of 48730 relevant lines covered (65.26%)

1.37 hits per line

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

0.0
/backend/services/deviceauth/cache/mocks/Cache.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
        model "github.com/mendersoftware/mender-server/services/deviceauth/model"
23
        mock "github.com/stretchr/testify/mock"
24

25
        ratelimits "github.com/mendersoftware/mender-server/pkg/ratelimits"
26

27
        time "time"
28
)
29

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

35
// CacheCheckInTime provides a mock function with given fields: ctx, t, tid, id
36
func (_m *Cache) CacheCheckInTime(ctx context.Context, t *time.Time, tid string, id string) error {
×
37
        ret := _m.Called(ctx, t, tid, id)
×
38

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

43
        var r0 error
×
44
        if rf, ok := ret.Get(0).(func(context.Context, *time.Time, string, string) error); ok {
×
45
                r0 = rf(ctx, t, tid, id)
×
46
        } else {
×
47
                r0 = ret.Error(0)
×
48
        }
×
49

50
        return r0
×
51
}
52

53
// CacheLimits provides a mock function with given fields: ctx, l, tid, id, idtype
54
func (_m *Cache) CacheLimits(ctx context.Context, l ratelimits.ApiLimits, tid string, id string, idtype string) error {
×
55
        ret := _m.Called(ctx, l, tid, id, idtype)
×
56

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

61
        var r0 error
×
62
        if rf, ok := ret.Get(0).(func(context.Context, ratelimits.ApiLimits, string, string, string) error); ok {
×
63
                r0 = rf(ctx, l, tid, id, idtype)
×
64
        } else {
×
65
                r0 = ret.Error(0)
×
66
        }
×
67

68
        return r0
×
69
}
70

71
// CacheToken provides a mock function with given fields: ctx, tid, id, idtype, token, expireSec
72
func (_m *Cache) CacheToken(ctx context.Context, tid string, id string, idtype string, token string, expireSec time.Duration) error {
×
73
        ret := _m.Called(ctx, tid, id, idtype, token, expireSec)
×
74

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

79
        var r0 error
×
80
        if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string, time.Duration) error); ok {
×
81
                r0 = rf(ctx, tid, id, idtype, token, expireSec)
×
82
        } else {
×
83
                r0 = ret.Error(0)
×
84
        }
×
85

86
        return r0
×
87
}
88

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

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

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

NEW
104
        return r0
×
105
}
106

107
// DeleteToken provides a mock function with given fields: ctx, tid, id, idtype
108
func (_m *Cache) DeleteToken(ctx context.Context, tid string, id string, idtype string) error {
×
109
        ret := _m.Called(ctx, tid, id, idtype)
×
110

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

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

122
        return r0
×
123
}
124

125
// GetCheckInTime provides a mock function with given fields: ctx, tid, id
126
func (_m *Cache) GetCheckInTime(ctx context.Context, tid string, id string) (*time.Time, error) {
×
127
        ret := _m.Called(ctx, tid, id)
×
128

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

133
        var r0 *time.Time
×
134
        var r1 error
×
135
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*time.Time, error)); ok {
×
136
                return rf(ctx, tid, id)
×
137
        }
×
138
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *time.Time); ok {
×
139
                r0 = rf(ctx, tid, id)
×
140
        } else {
×
141
                if ret.Get(0) != nil {
×
142
                        r0 = ret.Get(0).(*time.Time)
×
143
                }
×
144
        }
145

146
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
×
147
                r1 = rf(ctx, tid, id)
×
148
        } else {
×
149
                r1 = ret.Error(1)
×
150
        }
×
151

152
        return r0, r1
×
153
}
154

155
// GetCheckInTimes provides a mock function with given fields: ctx, tid, ids
156
func (_m *Cache) GetCheckInTimes(ctx context.Context, tid string, ids []string) ([]*time.Time, error) {
×
157
        ret := _m.Called(ctx, tid, ids)
×
158

×
159
        if len(ret) == 0 {
×
160
                panic("no return value specified for GetCheckInTimes")
×
161
        }
162

163
        var r0 []*time.Time
×
164
        var r1 error
×
165
        if rf, ok := ret.Get(0).(func(context.Context, string, []string) ([]*time.Time, error)); ok {
×
166
                return rf(ctx, tid, ids)
×
167
        }
×
168
        if rf, ok := ret.Get(0).(func(context.Context, string, []string) []*time.Time); ok {
×
169
                r0 = rf(ctx, tid, ids)
×
170
        } else {
×
171
                if ret.Get(0) != nil {
×
172
                        r0 = ret.Get(0).([]*time.Time)
×
173
                }
×
174
        }
175

176
        if rf, ok := ret.Get(1).(func(context.Context, string, []string) error); ok {
×
177
                r1 = rf(ctx, tid, ids)
×
178
        } else {
×
179
                r1 = ret.Error(1)
×
180
        }
×
181

182
        return r0, r1
×
183
}
184

185
// GetLimit provides a mock function with given fields: ctx, name
NEW
186
func (_m *Cache) GetLimit(ctx context.Context, name string) (*model.Limit, error) {
×
NEW
187
        ret := _m.Called(ctx, name)
×
NEW
188

×
NEW
189
        if len(ret) == 0 {
×
NEW
190
                panic("no return value specified for GetLimit")
×
191
        }
192

NEW
193
        var r0 *model.Limit
×
NEW
194
        var r1 error
×
NEW
195
        if rf, ok := ret.Get(0).(func(context.Context, string) (*model.Limit, error)); ok {
×
NEW
196
                return rf(ctx, name)
×
NEW
197
        }
×
NEW
198
        if rf, ok := ret.Get(0).(func(context.Context, string) *model.Limit); ok {
×
NEW
199
                r0 = rf(ctx, name)
×
NEW
200
        } else {
×
NEW
201
                if ret.Get(0) != nil {
×
NEW
202
                        r0 = ret.Get(0).(*model.Limit)
×
NEW
203
                }
×
204
        }
205

NEW
206
        if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
×
NEW
207
                r1 = rf(ctx, name)
×
NEW
208
        } else {
×
NEW
209
                r1 = ret.Error(1)
×
NEW
210
        }
×
211

NEW
212
        return r0, r1
×
213
}
214

215
// GetLimits provides a mock function with given fields: ctx, tid, id, idtype
216
func (_m *Cache) GetLimits(ctx context.Context, tid string, id string, idtype string) (*ratelimits.ApiLimits, error) {
×
217
        ret := _m.Called(ctx, tid, id, idtype)
×
218

×
219
        if len(ret) == 0 {
×
220
                panic("no return value specified for GetLimits")
×
221
        }
222

223
        var r0 *ratelimits.ApiLimits
×
224
        var r1 error
×
225
        if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*ratelimits.ApiLimits, error)); ok {
×
226
                return rf(ctx, tid, id, idtype)
×
227
        }
×
228
        if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *ratelimits.ApiLimits); ok {
×
229
                r0 = rf(ctx, tid, id, idtype)
×
230
        } else {
×
231
                if ret.Get(0) != nil {
×
232
                        r0 = ret.Get(0).(*ratelimits.ApiLimits)
×
233
                }
×
234
        }
235

236
        if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok {
×
237
                r1 = rf(ctx, tid, id, idtype)
×
238
        } else {
×
239
                r1 = ret.Error(1)
×
240
        }
×
241

242
        return r0, r1
×
243
}
244

245
// SetLimit provides a mock function with given fields: ctx, limit
NEW
246
func (_m *Cache) SetLimit(ctx context.Context, limit *model.Limit) error {
×
NEW
247
        ret := _m.Called(ctx, limit)
×
NEW
248

×
NEW
249
        if len(ret) == 0 {
×
NEW
250
                panic("no return value specified for SetLimit")
×
251
        }
252

NEW
253
        var r0 error
×
NEW
254
        if rf, ok := ret.Get(0).(func(context.Context, *model.Limit) error); ok {
×
NEW
255
                r0 = rf(ctx, limit)
×
NEW
256
        } else {
×
NEW
257
                r0 = ret.Error(0)
×
NEW
258
        }
×
259

NEW
260
        return r0
×
261
}
262

263
// SuspendTenant provides a mock function with given fields: ctx, tid
264
func (_m *Cache) SuspendTenant(ctx context.Context, tid string) error {
×
265
        ret := _m.Called(ctx, tid)
×
266

×
267
        if len(ret) == 0 {
×
268
                panic("no return value specified for SuspendTenant")
×
269
        }
270

271
        var r0 error
×
272
        if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
×
273
                r0 = rf(ctx, tid)
×
274
        } else {
×
275
                r0 = ret.Error(0)
×
276
        }
×
277

278
        return r0
×
279
}
280

281
// Throttle provides a mock function with given fields: ctx, rawToken, l, tid, id, idtype, url, action
282
func (_m *Cache) Throttle(ctx context.Context, rawToken string, l ratelimits.ApiLimits, tid string, id string, idtype string, url string, action string) (string, error) {
×
283
        ret := _m.Called(ctx, rawToken, l, tid, id, idtype, url, action)
×
284

×
285
        if len(ret) == 0 {
×
286
                panic("no return value specified for Throttle")
×
287
        }
288

289
        var r0 string
×
290
        var r1 error
×
291
        if rf, ok := ret.Get(0).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) (string, error)); ok {
×
292
                return rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
293
        }
×
294
        if rf, ok := ret.Get(0).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) string); ok {
×
295
                r0 = rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
296
        } else {
×
297
                r0 = ret.Get(0).(string)
×
298
        }
×
299

300
        if rf, ok := ret.Get(1).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) error); ok {
×
301
                r1 = rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
302
        } else {
×
303
                r1 = ret.Error(1)
×
304
        }
×
305

306
        return r0, r1
×
307
}
308

309
// NewCache creates a new instance of Cache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
310
// The first argument is typically a *testing.T value.
311
func NewCache(t interface {
312
        mock.TestingT
313
        Cleanup(func())
314
}) *Cache {
×
315
        mock := &Cache{}
×
316
        mock.Mock.Test(t)
×
317

×
318
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
319

320
        return mock
×
321
}
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