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

mendersoftware / mender-server / 1550767116

19 Nov 2024 11:58AM UTC coverage: 72.563% (-0.2%) from 72.771%
1550767116

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

4174 of 6072 branches covered (68.74%)

Branch coverage included in aggregate %.

135 of 380 new or added lines in 8 files covered. (35.53%)

84 existing lines in 3 files now uncovered.

42593 of 58378 relevant lines covered (72.96%)

15.45 hits per line

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

58.79
/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 {
1✔
37
        ret := _m.Called(ctx, t, tid, id)
1✔
38

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

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

50
        return r0
1✔
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 {
1✔
55
        ret := _m.Called(ctx, l, tid, id, idtype)
1✔
56

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

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

68
        return r0
1✔
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 {
1✔
73
        ret := _m.Called(ctx, tid, id, idtype, token, expireSec)
1✔
74

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

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

86
        return r0
1✔
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 {
1✔
109
        ret := _m.Called(ctx, tid, id, idtype)
1✔
110

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

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

122
        return r0
1✔
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) {
1✔
127
        ret := _m.Called(ctx, tid, id)
1✔
128

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

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

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

152
        return r0, r1
1✔
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) {
1✔
157
        ret := _m.Called(ctx, tid, ids)
1✔
158

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

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

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

182
        return r0, r1
1✔
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) {
1✔
217
        ret := _m.Called(ctx, tid, id, idtype)
1✔
218

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

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

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

242
        return r0, r1
1✔
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 {
1✔
265
        ret := _m.Called(ctx, tid)
1✔
266

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

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

278
        return r0
1✔
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) {
1✔
283
        ret := _m.Called(ctx, rawToken, l, tid, id, idtype, url, action)
1✔
284

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

289
        var r0 string
1✔
290
        var r1 error
1✔
291
        if rf, ok := ret.Get(0).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) (string, error)); ok {
1✔
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 {
1✔
295
                r0 = rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
296
        } else {
1✔
297
                r0 = ret.Get(0).(string)
1✔
298
        }
1✔
299

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

306
        return r0, r1
1✔
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