• 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

76.47
/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
        ratelimits "github.com/mendersoftware/mender-server/pkg/ratelimits"
23
        mock "github.com/stretchr/testify/mock"
24

25
        time "time"
26
)
27

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

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

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

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

48
        return r0
1✔
49
}
50

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

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

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

66
        return r0
1✔
67
}
68

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

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

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

84
        return r0
1✔
85
}
86

87
// DeleteToken provides a mock function with given fields: ctx, tid, id, idtype
88
func (_m *Cache) DeleteToken(ctx context.Context, tid string, id string, idtype string) error {
1✔
89
        ret := _m.Called(ctx, tid, id, idtype)
1✔
90

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

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

102
        return r0
1✔
103
}
104

105
// GetCheckInTime provides a mock function with given fields: ctx, tid, id
106
func (_m *Cache) GetCheckInTime(ctx context.Context, tid string, id string) (*time.Time, error) {
1✔
107
        ret := _m.Called(ctx, tid, id)
1✔
108

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

113
        var r0 *time.Time
1✔
114
        var r1 error
1✔
115
        if rf, ok := ret.Get(0).(func(context.Context, string, string) (*time.Time, error)); ok {
1✔
NEW
116
                return rf(ctx, tid, id)
×
NEW
117
        }
×
118
        if rf, ok := ret.Get(0).(func(context.Context, string, string) *time.Time); ok {
1✔
119
                r0 = rf(ctx, tid, id)
×
120
        } else {
1✔
121
                if ret.Get(0) != nil {
2✔
122
                        r0 = ret.Get(0).(*time.Time)
1✔
123
                }
1✔
124
        }
125

126
        if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
1✔
UNCOV
127
                r1 = rf(ctx, tid, id)
×
128
        } else {
1✔
129
                r1 = ret.Error(1)
1✔
130
        }
1✔
131

132
        return r0, r1
1✔
133
}
134

135
// GetCheckInTimes provides a mock function with given fields: ctx, tid, ids
136
func (_m *Cache) GetCheckInTimes(ctx context.Context, tid string, ids []string) ([]*time.Time, error) {
1✔
137
        ret := _m.Called(ctx, tid, ids)
1✔
138

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

143
        var r0 []*time.Time
1✔
144
        var r1 error
1✔
145
        if rf, ok := ret.Get(0).(func(context.Context, string, []string) ([]*time.Time, error)); ok {
1✔
NEW
146
                return rf(ctx, tid, ids)
×
NEW
147
        }
×
148
        if rf, ok := ret.Get(0).(func(context.Context, string, []string) []*time.Time); ok {
1✔
149
                r0 = rf(ctx, tid, ids)
×
150
        } else {
1✔
151
                if ret.Get(0) != nil {
2✔
152
                        r0 = ret.Get(0).([]*time.Time)
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, tid, ids)
×
158
        } else {
1✔
159
                r1 = ret.Error(1)
1✔
160
        }
1✔
161

162
        return r0, r1
1✔
163
}
164

165
// GetLimits provides a mock function with given fields: ctx, tid, id, idtype
166
func (_m *Cache) GetLimits(ctx context.Context, tid string, id string, idtype string) (*ratelimits.ApiLimits, error) {
1✔
167
        ret := _m.Called(ctx, tid, id, idtype)
1✔
168

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

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

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

192
        return r0, r1
1✔
193
}
194

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

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

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

210
        return r0
1✔
211
}
212

213
// Throttle provides a mock function with given fields: ctx, rawToken, l, tid, id, idtype, url, action
214
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✔
215
        ret := _m.Called(ctx, rawToken, l, tid, id, idtype, url, action)
1✔
216

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

221
        var r0 string
1✔
222
        var r1 error
1✔
223
        if rf, ok := ret.Get(0).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) (string, error)); ok {
1✔
NEW
224
                return rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
NEW
225
        }
×
226
        if rf, ok := ret.Get(0).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) string); ok {
1✔
227
                r0 = rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
228
        } else {
1✔
229
                r0 = ret.Get(0).(string)
1✔
230
        }
1✔
231

232
        if rf, ok := ret.Get(1).(func(context.Context, string, ratelimits.ApiLimits, string, string, string, string, string) error); ok {
1✔
UNCOV
233
                r1 = rf(ctx, rawToken, l, tid, id, idtype, url, action)
×
234
        } else {
1✔
235
                r1 = ret.Error(1)
1✔
236
        }
1✔
237

238
        return r0, r1
1✔
239
}
240

241
// 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.
242
// The first argument is typically a *testing.T value.
243
func NewCache(t interface {
244
        mock.TestingT
245
        Cleanup(func())
NEW
246
}) *Cache {
×
NEW
247
        mock := &Cache{}
×
NEW
248
        mock.Mock.Test(t)
×
NEW
249

×
NEW
250
        t.Cleanup(func() { mock.AssertExpectations(t) })
×
251

NEW
252
        return mock
×
253
}
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